首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

useBean多谢

2013-09-11 
useBean谢谢counter:public class counter {private int count0public void setcount(int count){this.c

useBean谢谢
counter:
public class counter {

private int count=0;

public void setcount(int count){
this.count=count;
}
public int getcount(){
return ++count;
}

}

counter.jsp
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<html>
<head>
<title>con</title>
</head>
<body><br/>
<jsp:useBean id="personCount" class="counter" scope="session" />
<jsp:useBean id="totalCount" class="counter" scope="application" />

<jsp:getProperty name="personCount" property="count" />

</body>
</html>


HTTP Status 500 - 

--------------------------------------------

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 7 in the jsp file: /counter.jsp
counter cannot be resolved to a type
4: <title>con</title>
5: </head>
6: <body><br/>
7: <jsp:useBean id="personCount" class="counter" scope="session" />
8: <jsp:useBean id="totalCount" class="counter" scope="application" />
9: 
10: <jsp:getProperty name="personCount" property="count" />


An error occurred at line: 7 in the jsp file: /counter.jsp
counter cannot be resolved to a type
4: <title>con</title>
5: </head>
6: <body><br/>
7: <jsp:useBean id="personCount" class="counter" scope="session" />
8: <jsp:useBean id="totalCount" class="counter" scope="application" />
9: 
10: <jsp:getProperty name="personCount" property="count" />


An error occurred at line: 7 in the jsp file: /counter.jsp
counter cannot be resolved to a type
4: <title>con</title>
5: </head>
6: <body><br/>
7: <jsp:useBean id="personCount" class="counter" scope="session" />
8: <jsp:useBean id="totalCount" class="counter" scope="application" />
9: 
10: <jsp:getProperty name="personCount" property="count" />


An error occurred at line: 8 in the jsp file: /counter.jsp
counter cannot be resolved to a type
5: </head>
6: <body><br/>
7: <jsp:useBean id="personCount" class="counter" scope="session" />
8: <jsp:useBean id="totalCount" class="counter" scope="application" />
9: 
10: <jsp:getProperty name="personCount" property="count" />
11: 


An error occurred at line: 8 in the jsp file: /counter.jsp
counter cannot be resolved to a type
5: </head>
6: <body><br/>
7: <jsp:useBean id="personCount" class="counter" scope="session" />
8: <jsp:useBean id="totalCount" class="counter" scope="application" />
9: 
10: <jsp:getProperty name="personCount" property="count" />
11: 


An error occurred at line: 8 in the jsp file: /counter.jsp
counter cannot be resolved to a type
5: </head>
6: <body><br/>
7: <jsp:useBean id="personCount" class="counter" scope="session" />


8: <jsp:useBean id="totalCount" class="counter" scope="application" />
9: 
10: <jsp:getProperty name="personCount" property="count" />
11: 


An error occurred at line: 10 in the jsp file: /counter.jsp
counter cannot be resolved to a type
7: <jsp:useBean id="personCount" class="counter" scope="session" />
8: <jsp:useBean id="totalCount" class="counter" scope="application" />
9: 
10: <jsp:getProperty name="personCount" property="count" />
11: 
12: </body>
13: </html>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------

用Myeclipse 9.0 class="counter"能找到,为什么还会出这情况?

[解决办法]
It looks as if the counter class is not in a package - all JSP beans need to be in a package.

You'll also need a JSP import statement for that package/class.
[解决办法]
class="counter" 必须要 包名加上类名
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html

热点排行