I have the following sources:
struts.xml
<s:select list = "categories"
key = "product.search.category" />
You are listing a List<String>
and trying to access, through OGNL .
(dot notation), fields that do not exist.
In OGNL
product.search.category
is the equivalent of Java
getProduct().getSearch().getCategory()
Since you are listing Strings, just omit key attribute, because both your key and value will be the String itself.
It seems that you are confusing key
with name
too: key
is the key of the <option>
element, while name
is the Action's attribute that will receive the chosen value through its Setter.
<s:select list = "categories"
name = "chosenCategory" />
EDIT: for a succesful living, implement Preparable Interface and load there your "static" data:
public class ProductSearchAction extends ActionSupport implements Preparable {
private List<String> categories;
private String chosenCategory;
@override
public void prepare() throws Exception {
categories = new ArrayList<String>();
categories.add("Eins");
categories.add("Zwei");
categories.add("Drei");
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
/* GETTERS AND SETTERS */
}
And you must specify fully qualified class names for each tag in struts.xml...