JSP导入没有错误但不起作用

时间:2015-08-01 16:35:41

标签: java jsp jstl

使用JSP和JSTL,我试图将Constant类导入到我的模板中。在我的文件顶部,我有:

<%@ page import="app.util.Constant" %>

这不会引发任何错误,但我非常确定该文件是否正确编译,因为如果我尝试,我会收到编译错误:

<%@ page import="app.util.DoesntExist" %>

尽管有效,但我无法在其上引用Constant类或属性:

<c:if test="${Constant == null}">
    <c:out value="foo"/>
</c:if>
<c:if test="${Constant.LOGIN_URL == null}">
    <c:out value="bar"/>
</c:if>

将打印foobar。如何在不诉诸<%= Constant.LOGIN_URL %>的情况下引用此课程?

在我的Constant课程中,我有:

public static final String LOGIN_URL = "login";
public static final String getLOGIN_URL() {
    return LOGIN_URL;
}

提前致谢。

0 个答案:

没有答案