java类无法解析为类型(jsp)
我不熟悉jsp。我在学习useBean方法,在
http://www.studytonight.com/jsp/getproperty-tag.php
向下滚动,你会找到它
这是我的jsp文件:
<html> <head> <title>Welcome Page</title> </head> <jsp:useBean id="person" type="PersonBean" scope="request"/> <body> Hello, <jsp:getProperty name="person" property="name"/> </body> </html>
这是我的PersonBean。java文件,编译成类文件并放入 类文件:
import java.io.Serializable; public class PersonBean implements Serializable { private String name="Hello World"; public PersonBean() { this.name="Hello"; } public void setName(String name) { this.name = name; } public String getName() { return name; } }
我得到了一个错误: jsp文件:/hello1的第5行出现错误。jsp PersonBean无法解析为类型
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 5 in the jsp file: /hello1.jsp PersonBean cannot be resolved to a type 2: <head> 3: <title>Welcome Page</title> 4: </head> 5: <jsp:useBean id="person" type="PersonBean" scope="request"/> 6: <body> 7: Hello, <jsp:getProperty name="person" property="name"/> 8: </body> An error occurred at line: 5 in the jsp file: /hello1.jsp PersonBean cannot be resolved to a type 2: <head> 3: <title>Welcome Page</title> 4: </head> 5: <jsp:useBean id="person" type="PersonBean" scope="request"/> 6: <body> 7: Hello, <jsp:getProperty name="person" property="name"/> 8: </body> An error occurred at line: 7 in the jsp file: /hello1.jsp PersonBean cannot be resolved to a type 4: </head> 5: <jsp:useBean id="person" type="PersonBean" scope="request"/> 6: <body> 7: Hello, <jsp:getProperty name="person" property="name"/> 8: </body> 9: </html> An error occurred at line: 7 in the jsp file: /hello1.jsp PersonBean cannot be resolved to a type 4: </head> 5: <jsp:useBean id="person" type="PersonBean" scope="request"/> 6: <body> 7: Hello, <jsp:getProperty name="person" property="name"/> 8: </body> 9: </html> Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:490) org.apache.jasper.compiler.Compiler.compile(Compiler.java:379) org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.70 logs.
共 (0) 个答案