当前位置: 技术问答>java相关
在Tomcat中,JSP怎样调用beans ?
来源: 互联网 发布时间:2015-04-25
本文导语: 编译Hello.java并保存在当前目录(webappsjszyjspbeansexample_h) 调用文件example.jsp在下(webappsjszyjsp) 用http://myServer:8080/jszy/jsp/example.jsp访问,出错提示: org.apache.jasper.JasperException: Unable to compile class for JSPC:tomcatworklocalh...
编译Hello.java并保存在当前目录(webappsjszyjspbeansexample_h)
调用文件example.jsp在下(webappsjszyjsp)
用http://myServer:8080/jszy/jsp/example.jsp访问,出错提示:
org.apache.jasper.JasperException: Unable to compile class for JSPC:tomcatworklocalhost_8080%2Fjszy_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:63: ???? example_h.Hello?
example_h.Hello HelloBeans = null;
^
C:tomcatworklocalhost_8080%2Fjszy_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:66: ???? example_h.Hello?
HelloBeans= (example_h.Hello)
^
C:tomcatworklocalhost_8080%2Fjszy_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:71: ???? example_h.Hello?
HelloBeans = (example_h.Hello) Beans.instantiate(this.getClass().getClassLoader(), "example_h.Hello");
^
3 ???
.......
=======================================================================
Hello.java原文件:
package example_h;
public class Hello {
public String name="Every one!";
public String output() {
return "Hello "+name;
}
}
-----------------------------------------------------------------------
example.jsp原文件:
====================================================================
问题出在哪?
调用文件example.jsp在下(webappsjszyjsp)
用http://myServer:8080/jszy/jsp/example.jsp访问,出错提示:
org.apache.jasper.JasperException: Unable to compile class for JSPC:tomcatworklocalhost_8080%2Fjszy_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:63: ???? example_h.Hello?
example_h.Hello HelloBeans = null;
^
C:tomcatworklocalhost_8080%2Fjszy_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:66: ???? example_h.Hello?
HelloBeans= (example_h.Hello)
^
C:tomcatworklocalhost_8080%2Fjszy_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:71: ???? example_h.Hello?
HelloBeans = (example_h.Hello) Beans.instantiate(this.getClass().getClassLoader(), "example_h.Hello");
^
3 ???
.......
=======================================================================
Hello.java原文件:
package example_h;
public class Hello {
public String name="Every one!";
public String output() {
return "Hello "+name;
}
}
-----------------------------------------------------------------------
example.jsp原文件:
====================================================================
问题出在哪?
|
在下面加上下面这句话试试
|
javabeans应该放在classes下面