日期:2014-05-18  浏览次数:20755 次

JavaBean问题?
javaBean==
import   java.io.*;
public   class   Circle
{
int   radius;
public   Circle()
{
radius=1;
}
public   int   getRadius()
{
return   radius;
}
public   void   setRadius(int   newRadius)
{
radius=newRadius;
}
public   double   circleArea()
{
return   Math.PI*radius*radius;
}
public   double   circleLength()
{
return   2.0*Math.PI*radius;
}
}
======
<%@   page   contentType= "text/html;charset=GB2312 "%>
<%@   page   import= "Circle "%>

<html>
<body   bgcolor= "cyan "> <font   size=1>
<jsp:useBean   id= "girl "   class= "Circle "   scope= "page "/>
<%//设置园的半径
    girl.setRadius(100);
%>
<p> 圆的半径是:
<%=girl.getRadius()%>
<p> 圆的周长是:
<%=girl.circleLength()%>
<p> 圆的面积是:
<%=girl.circleArea()%>
</body>
</html>
-=-=-=-=-=-=-=-=
org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP

Generated   servlet   error:
E:\Tomcat   5.0\work\Catalina\localhost\tow\org\apache\jsp\useBeans_jsp.java:6:   '. '   expected
import   Circle;
                          ^
1   error
我好几个地方都碰到了,请问怎么回事?

------解决方案--------------------
<%@ page contentType= "text/html;charset=GB2312 "%>
<%@ page import= "csdn002.Circle "%>
<html>
<body bgcolor= "cyan ">
<font size=1>
<jsp:useBean id= "girl " class= "Circle " scope= "page "/>
<%//设置园的半径
girl.setRadius(100);
%>
<p> 圆的半径是:
<%=girl.getRadius()%>
<p> 圆的周长是:
<%=girl.circleLength()%>
<p> 圆的面积是:
<%=girl.circleArea()%>
</font>
</body>
</html>
------解决方案--------------------
<%@ page import= "csdn002.Circle "%>
加上包名
------解决方案--------------------
把你的BEAN加个包名试试.
------解决方案--------------------
好像JSP用到的javaBean需要加包名

试试如下
package test;
import java.io.*;
public class Circle
{
int radius;
public Circle()
{
radius=1;
}
public int getRadius()
{
return radius;
}
public void setRadius(int newRadius)
{
radius=newRadius;
}
public double circleArea()
{
return Math.PI*radius*radius;
}
public double circleLength()
{
return 2.0*Math.PI*radius;
}
}
======
<%@ page contentType= "text/html;charset=GB2312 "%>
<%@ page import= "test.Circle "%>

<html>
<body bgcolor= "cyan "> <font size=1>
<jsp:useBean id= "girl " class= "Circle " scope= "page "/>
<%//设置园的半径
girl.setRadius