使用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>
将打印foo
和bar
。如何在不诉诸<%= Constant.LOGIN_URL %>
的情况下引用此课程?
在我的Constant
课程中,我有:
public static final String LOGIN_URL = "login";
public static final String getLOGIN_URL() {
return LOGIN_URL;
}
提前致谢。