无法将类导入JSP [英] Trouble importing classes to JSP

查看:107
本文介绍了无法将类导入JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

凭借其智慧 jspc 告诉我以下关于我的一个 JSP s

In it's wisdom jspc told me the following about one of my JSPs

[ERROR] MyClassName cannot be resolved to a type

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

Indeed it was not there.. Hmm .. Lets include it!

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

好的,现在 jspc

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

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

That's simply is not true, but ok, lets try wildcarding it

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

jspc 返回原始错误

[ERROR] MyClassName cannot be resolved to a type

任何想法?

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

Confirmed: issue is isolated to the build time. At run time, assuming all imports are done as shown above, everything works.

推荐答案

在我的理解中 com.abcMyClassName 位于JSP无法访问的类加载器中。

In my understanding com.a.b.c.MyClassName is in a Class Loader not accessible by the JSP.

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

This can happen if you have multiple web applications and the JSP is in a web app and the class in another.

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

To test that simply put the class in the app server global classpath.

这篇关于无法将类导入JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆