无法将类导入JSP

时间:2012-12-03 21:30:01

标签: java jsp intellij-idea

在它的智慧中jspc告诉我以下关于JSP的一个

[ERROR] MyClassName cannot be resolved to a type

确实不存在..嗯..让我们把它包括在内!

<%@ page import="com.a.b.c.MyClassName"%>

好的,现在jspc

[ERROR] Only a type can be imported. com.a.b.c.MyClassName resolves to a package

这根本不是真的,但好吧,让我们尝试通配它

<%@ page import="com.a.b.c.*"%>

jspc返回原始错误

[ERROR] MyClassName cannot be resolved to a type

有什么想法吗?


更新

确认:问题与构建时间隔离。在运行时,假设所有导入都如上所示完成,一切正常。

2 个答案:

答案 0 :(得分:0)

看起来您的JSP配置没有指向该类的JAR /资源的链接。

一些可能有用的链接:

The same problem as yours

A JAR include problem leading to the same error

A Tomcat config problem leading... to the same

我希望这些链接很有用。

答案 1 :(得分:0)

在我的理解中,com.a.b.c.MyClassName位于JSP无法访问的类加载器中。

如果您有多个Web应用程序且JSP位于Web应用程序中而该类位于另一个Web应用程序中,则会发生这种情况。

测试只是将类放在app server全局类路径中。

相关问题