There's no reason to get an object from the request in Struts2. If you are using Struts2 tag you can get the object from the valueStack
via OGNL. However in Struts2 is possible to get the value from the request attributes using OGNL. For this purpose you should access the OGNL context variable request
. For example
<s:select list="%{#request.repTypList}" listKey="id" listValue="val" />
The select
tag requires not null
value returned via OGNL expression in the list
tag, as a result of null
value you got the error. So, better to check this in the action before the result is returned.
public class showSchdulesAction extends ActionSupport
public String execute() throws Exception {
...
HttpServletRequest request = ServletActionContext.getRequest();
List list = someObj.getCommonList();
if (list == null) list = new ArrayList();
request.setAttribute("repTypList", list);
...
}
}
This code will save you from the error above.