Web*_*net 1 java spring-mvc taglib
我正在尝试使用<form:select>标记在我的编辑内容.jsp中使用以下ENUM ,但无法找到有关如何执行此操作的示例.
public class Content implements Serializable {
public enum Paperless {
NONE(null, ""),
EDELIVERY_RECOMMENDED("EDELIVERY_RECOMMENDED", "Recommend eDelivery"),
EDELIVERY_REQUIRED("EDELIVERY_REQUIRED", "Require eDelivery"),
EDELIVERY_REQUIRED_JUSTIFICATION("EDELIVERY_REQUIRED_JUSTIFICATION", "Require eDelivery w/out justification");
private String name;
private String description;
Paperless(String name, String description) {
this.name = name;
this.description = description;
}
public String getName() {
return this.name;
}
public String getDescription() {
return this.description;
}
}
....
Run Code Online (Sandbox Code Playgroud)
上面的内容对象传递给我的.jsp文件${content}.
我正在努力做到
<form:select path="content.Paperless">
<form:options items="${content.Paperless}" itemLabel="name"/>
</form:select>
Run Code Online (Sandbox Code Playgroud)
这是一个例外......
org.springframework.beans.NotReadablePropertyException: Invalid property 'content' of bean class [com.fettergroup.cmt.model.Content]: Bean property 'content' is not readable or has an invalid getter method: Does the return type of the getter match the parameter
我对此有些误解,但我无法确定哪一个......
您的<form:select>路径是指一个名为getContent()的getter,它返回一个具有getter getPaperless()的对象.也许你想在你的动作模型类上使用getPaperless().
然后要显示枚举值列表,您只需要声明一个空选项标记:
<form:select path="paperless">
<form:options/>
</form:select>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13950 次 |
| 最近记录: |