简体   繁体   English

使用JSP页面导入时找不到符号错误

[英]Cannot Find Symbol error when using jsp page import

I have been trying to import a java class into a jsp page using the typical syntax: 我一直在尝试使用典型语法将Java类导入到jsp页面中:

<%@ page import="packageName.HelloWorldTest" %>

and

<%@ page import="packageName.* %>

Whenever I try I receive this error: 每当我尝试时,都会收到此错误:

PWC6199: Generated servlet error: cannot find symbol PWC6199:生成的servlet错误:找不到符号

symbol: class HelloWorldTest 符号:类HelloWorldTest

location: package packageName 位置:包packageName

PWC6197: An error occurred at line: 3 in the jsp file: /WEB-INF/jsp/test.jsp PWC6197:jsp文件:/WEB-INF/jsp/test.jsp中的第3行出现错误

PWC6199: Generated servlet error: cannot find symbol PWC6199:生成的servlet错误:找不到符号

symbol: variable HelloWorldTest 符号:变量HelloWorldTest

location: class org.apache.jsp.WEB_002dINF.jsp.test_jsp 位置:类org.apache.jsp.WEB_002dINF.jsp.test_jsp

I'm also using Maven. 我也在使用Maven。 I have reconfigured my project so that the default output folder is WEB-INF/classes, but I still receive this error. 我已经重新配置了项目,以使默认输出文件夹为WEB-INF / classes,但仍然收到此错误。

It's very likely that when your Maven build finishes you don't have any HelloWorldTest class generated inside /WEB-INF/classes/packageName/ folder. 当您的Maven构建完成时,很可能在/WEB-INF/classes/packageName/文件夹中没有生成任何HelloWorldTest类。 If not, you would need to fix your Maven configuration. 如果不是,则需要修复Maven配置。

If the class file is there, check your final war artifact that Maven is generating. 如果类文件在那里,请检查Maven生成的最终war工件。 Is the class there too? 上课了吗? If yes, check that the exploded war directory on your servlet container has the class file too (under /webapps folder in Tomcat). 如果是,请检查servlet容器上的分解war目录是否也具有类文件(在Tomcat的/webapps文件夹下)。

If the class file exists inside your app server too, check for any spelling mistakes in the package name specified in your JSP. 如果该类文件也存在于您的应用服务器中,请检查JSP中指定的包名称中是否存在拼写错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM