我在这个包里写了如下方法:package test;//import javax.servlet.http.fpublic class test1  { 
int y = 1;
public int yy() {
int i = 0;
return i;
}
 public int main(String args[]) { 
   int i=0,total=0; 
   while(i<4) { 
      i++; 
      if(i > 2) continue; 
      total += i; 
   } 
   System.out.println("rrrrrrrrrr"+total); 
   return total; 
 } 

在页面上进行这样的调用:
<%
test1 t = new test1();
System.out.println("test1:rrrrrrrrrrrrr"+t.yy);

%> 
总是提示我这样的错误:
symbol  : variable yy
location: class test.test1
System.out.println("test1:rrrrrrrrrrrrr"+t.yy);
                                                  ^
1 error

解决方案 »

  1.   

    System.out.println("test1:rrrrrrrrrrrrr"+t.yy());
      

  2.   

    谢谢楼上的,不过现在提示: javax.servlet.ServletException: test.test1.yy()I
      

  3.   

    你是怎么样把类引入到jsp文件里的?jsp代码多给出一点
    package packageName // 把这个类放到一个包里试试
    public class test1  { 
    int y = 1;
    public int yy() {
    ......
      

  4.   

    jsp:代码就是这些: test1 t = new test1();
    System.out.println("test1:ooooo"+t.yy());
      

  5.   

    出错信息如下: javax.servlet.ServletException: test.test1.yy()I
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.test_jsp._jspService(test_jsp.java:142)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      

  6.   


    package test // 把这个类放到一个包里试试
    public class test1  { 
    int y = 1;
    public int yy() {
    ......
    ---------------------
    上边这个文件,编译以后,把test1.class放到WEB-INF/classes/test里边
      

  7.   

    test1.java 里加上package test;
      

  8.   

    package test; 这句话我已经加入了