0
我是新來的JSP,以及有關於JSP和豆類的問題。JSP和豆類:在哪裏放置類文件
我創建了以下Java文件作爲一個bean,編譯它,並保存Java和C中的類文件:\ Program Files文件\ Apache軟件基金會\ Tomcat的7.0 \的webapps \ jspfiles \ WEB-INF \類文件夾:
package test;
public class Hello
{
private String str;
public void setStr (String value)
{
str = value;
}
public String getStr()
{
return str;
}
}
我的JSP文件test.jsp的,用下面的代碼是在C:\ Program Files文件\ Apache軟件基金會\ Tomcat的7.0 \的webapps \ jspfiles文件夾。
<!DOCTYPE html>
<%@ page contentType="text/html;charset=windows-1252"%>
<jsp:useBean id="test" class="test.Hello" scope="session"/>
當我打開test.jsp的文件(HTTP://本地主機:8082/jspfiles/test.jsp的),我得到這個錯誤:
HTTP Status 500 - /test.jsp (line: 4, column: 0) The value for the useBean class attribute test.Hello is invalid.
type Exception report
message /test.jsp (line: 4, column: 0) The value for the useBean class attribute test.Hello is invalid.
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /test.jsp (line: 4, column: 0) The value for the useBean class attribute test.Hello is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:149)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1234)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1182)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Generator.generate(Generator.java:3490)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.34 logs.
上面的什麼是錯的?
謝謝,它的工作。 – user1492667