注册 登录
编程论坛 J2EE论坛

关于此段jsp代码的问题,请教一下

wongshiang 发布于 2008-07-07 22:48, 1147 次点击
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY>
<P>请输入圆的半径 </p>
<BR>
<FORM name="form" action="" method=get>
<input type="text" name="input1" size="10">
<input type="SUBMIT" value="开始计算" name=submit>
</FORM>
<%!
public class Circle{
double r;
  Circle(double r){
  this.r=r;
}
public double getArea(){
  return Math.PI*r*r;
}
public double getPeremater(){
  return Math.PI*2*r;
}
}
%>
<%
String str=request.getParameter("input1");
double r;
if(str!=null)
{
  r=Double.parseDouble(str);
}
else
{
  r=1;
}
Circle circle=new Circle(r);
%>
<p>圆面积是:
<BR>
<%=circle.getArea()%>
<p>圆周长是:
<BR>
<%=circle.getPeremater()%>
</body>
</html>
我想问一下,如果我把
%>
<%
去掉为什么就运行不了,实际上,头和尾都没有改变啊,只是中间去掉而已,还希望高手指导
3 回复
#2
高寒2008-07-10 16:58
<%!......%>这个是声明信息
<%.......%>这个是java代码片段
所以去掉中间的会报错
另外:<%=......%>这个是输出信息,不能用分号结束.
#3
zj26102008-07-11 00:54
www.belrion.com 贝尔中国
www. 贝尔中国

anyone of you bought any wow gold from www.
or sold any gold to www. ? I was told they deliver and are good and fast
appreciate if anyone here can give me some feedback ^^
#4
marer2008-07-11 19:27
楼上的是老外吗?如果不是请不要用鸟语沟通
1