我想從我的jsp訪問常量接口,但它顯示以下錯誤。如何從jsp訪問java接口
Caused by: tag 'select', field 'list', name 'title':
The requested list key 'Constants.TITLE'
could not be resolved as a collection/array/map/enumeration/iterator type.
Example: people or people.{name} - [unknown location]
我的界面
public interface Constants {
public List<String> TITLE = Arrays.asList("Mr","Mrs","Ms","Miss");
// public String[] TITLE = {"MR","MRs"}; << does not work as well
//public static final String[] TITLE = {"MR","MRs"}; << does not work as well
}
我的JSP代碼
...
<%@page import="com.myconstants.Constants" %>
<head>
</head>
<body>
<s:form>
<s:select label="title" name="title" list="Constants.TITLE" value=" "/>
</s:form>
....
呃,請不要這樣做。把它放在一個類中,如果它真的很重要,就將它暴露爲一個靜態值。 – 2013-02-12 02:32:22
@DaveNewton,我不明白你會給我一個例子嗎? – 2013-02-12 02:33:28