【问题标题】:java tomcat: only a type can be imported. com.a.B resolves to a packagejava tomcat:只能导入一个类型。 com.a.B 解析为一个包
【发布时间】: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 不能很好地处理动态链接文件。

标签: java jsp tomcat web.xml


【解决方案1】:

我使用了动态链接文件,我通过将类复制到适当的位置解决了这个问题。它可能与我不知道的权限问题有关。至少现在我确定这个错误与找不到类有关。

感谢您的帮助。

【讨论】:

    猜你喜欢
    • 2015-10-02
    • 2017-12-20
    • 2013-04-04
    • 2016-06-09
    • 2011-10-01
    • 1970-01-01
    • 2010-12-23
    • 1970-01-01
    相关资源
    最近更新 更多