在我的 web 项目中,我有一个 Class A、Class B(这些类在其他项目中,但正在成功导入),它是在 CompServlet.java 中导入的。还有一个 ListComp.jsp ,它正在导入 CompServlet.java。我的问题是 ListComp.jsp 无法看到 A 类和 B 类。它给出错误 A 类型未解析为类型。
问问题
99 次
1 回答
0
Imports are not transitive. If class A imports class B, and class C imports class A, class C doesn't automatically import class B.
If you need to use the class B without typing its fully quelified name every time (com.foo.bar.B), then you need to import it. It's as simple as that.
That said, I concur with BalusC. Having Java code in JSPs is ugly, and should be avoided.
于 2013-04-20T07:17:15.637 回答