I think you can do this using OGNL syntax. For example, I have a list and a property in my action class, for example:
private List test; private String p = "a1"; // And their getters and setters public String execute() throws Exception { test = new ArrayList(); test.add("a"); test.add("b"); test.add("c"); test.add("d"); test.add("e"); return SUCCESS; }
All I need to do on my JSP page
<s:if test="%{p in test}"> Inside If block </s:if> <s:else> Inside Else block </s:else>
See the Struts 2 OGNL documentation for more details:
source share