【发布时间】:2010-11-23 14:49:40
【问题描述】:
我有以下项目结构:
./WEB-INF/web.xml
./WEB-INF/lib
./WEB-INF/classes/com/a/B.class
./index.jsp
当我尝试将此项目放入 tomcat webapp 并尝试执行 index.jsp 时出现错误:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. com.a.B resolves to a package
如果我尝试导入任何其他不存在的类名,我会得到完全相同的错误。
这是我的 web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index_canvas.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>B</servlet-name>
<servlet-class>com.a.B</servlet-class>
</servlet>
</web-app>
有什么想法吗?
谢谢!
【问题讨论】:
-
你还有一个名为
com.a.b的包吗? -
不,我没有。这就是整个应用程序。如果我输入导入 foo.bar 或任何其他名称,它会提供此错误。
-
看来问题没有再出现了。我试图弄清楚发生了什么变化。也许 tomcat 不能很好地处理动态链接文件。