Webnet Webnet - 1 year ago 95
Java Question

How to use Java ENUM with <form:select>

I'm trying to use the following ENUM inside my edit content .jsp using the

tag and can't find an example on how to do this.

public class Content implements Serializable {
public enum Paperless {
NONE(null, ""),

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;

The above content object is passed to my .jsp file as

I'm trying to do

<form:select path="content.Paperless">
<form:options items="${content.Paperless}" itemLabel="name"/>

It's throwing an exception....
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

I'm misunderstanding something about this but I can't pinpoint which one...

Answer Source

Your <form:select> path is referring to a getter with name getContent() that returns an object that has getter getPaperless(). Perhaps you wanted to use just getPaperless() on your action model class.

Then to show list of enum values you just need to declare an empty options tag:

<form:select path="paperless">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download