私はjspを初めて使用しています。私はuseBeanの方法を学んでいた、とクラスを型(jsp)に解決できません
http://www.studytonight.com/jsp/getproperty-tag.php
の例を下にスクロールしがあり、あなたはそれを見つけるでしょう。ここで
は私のJSPファイルです:
: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; } }
<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ファイル、クラスファイルにコンパイルし、 クラスファイル内に置かれています
エラーが発生しました: エラーが発生しましたライン:/hello1.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.
私はそれの多くを理解していませんでした。最初の点について詳しく説明できますか? –
@Karan Thakkarどのパッケージに 'PersonBean'クラスを追加しましたか? – Mihir
classes = "action.PersonBean" PersonBean.classファイルをWEB-INF/classes&WEB-INF/classes/actionに入れてください。パッケージアクションを追加しました。 WEB-INF/classes/actionにあるjavaファイルにコピーしてコンパイルします。 –