当前位置: 技术问答>java相关
关于jsp调用class出错的问题:
来源: 互联网 发布时间:2017-04-12
本文导语: 我在%TOMCAT_HOME%/webapps/ROOT/目录下新建了一个test.jsp文件,然后把这个jsp文件需调用的class文件放在了ROOT/WEB-INF/classes/目录下,然后在IE中敲http://localhost:8080/test.jsp就会出现如下错误,不知道什么原因,可以肯定代码没有问...
我在%TOMCAT_HOME%/webapps/ROOT/目录下新建了一个test.jsp文件,然后把这个jsp文件需调用的class文件放在了ROOT/WEB-INF/classes/目录下,然后在IE中敲http://localhost:8080/test.jsp就会出现如下错误,不知道什么原因,可以肯定代码没有问题。
An error occurred at line: 11 in the jsp file: /test.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:Program FilesApache GroupTomcat 4.1workStandalonelocalhost_test_jsp.java:51: cannot resolve symbol
symbol : class counter
location: class org.apache.jsp.test_jsp
counter counter = null;
^
An error occurred at line: 11 in the jsp file: /test.jsp
Generated servlet error:
C:Program FilesApache GroupTomcat 4.1workStandalonelocalhost_test_jsp.java:53: cannot resolve symbol
symbol : class counter
location: class org.apache.jsp.test_jsp
counter = (counter) pageContext.getAttribute("counter", PageContext.REQUEST_SCOPE);
^
An error occurred at line: 11 in the jsp file: /test.jsp
Generated servlet error:
C:Program FilesApache GroupTomcat 4.1workStandalonelocalhost_test_jsp.java:56: cannot resolve symbol
symbol : class counter
location: class org.apache.jsp.test_jsp
counter = (counter) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "counter");
^
An error occurred at line: 18 in the jsp file: /test.jsp
Generated servlet error:
C:Program FilesApache GroupTomcat 4.1workStandalonelocalhost_test_jsp.java:71: cannot resolve symbol
symbol : variable cont
location: class org.apache.jsp.test_jsp
counter.WriteFile("/lyfcount.txt",cont);
^
An error occurred at line: 19 in the jsp file: /test.jsp
Generated servlet error:
C:Program FilesApache GroupTomcat 4.1workStandalonelocalhost_test_jsp.java:74: cannot resolve symbol
symbol : variable cont
location: class org.apache.jsp.test_jsp
out.print(cont);
^
|
你在环境变量中写错了,写成这样:
C:Program FilesApache GroupTomcat 4.1webappsWEB-INFclasses
C:Program FilesApache GroupTomcat 4.1webappsWEB-INFclasses
|
类是不是放在包里的,如是就在class下建立一个和包同名的文件夹(区分大小写)然后将类放在该文件夹下
|
你有没有将你的class的路径写入环境变量?
|
http://localhost:8080/test.jsp
->
http://localhost:8080/root/test.jsp
应该是没找到你的bean如果bean里有package
要放在:classes/package/*.class
->
http://localhost:8080/root/test.jsp
应该是没找到你的bean如果bean里有package
要放在:classes/package/*.class
|
class 编译通过吗?