Struts 2 tips
Filters
org.apache.struts2.dispatcher.FilterDispatcher and org.apache.struts2.dispatcher.ActionContextCleanUp filters are now deprecated (Struts 2.1.x), but most wiki resources and maven archetypes are not updated yet.
According to WW-2167, these 2 filters are broken and can even create memory leaks.
The new filters are : org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter and org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
Security
Don’t forget to look at security bulletins. There are some pretty bad vulnerabilities issues on versions < 2.0.12, including a “remote code exploit” and a “Directory traversal vulnerability“.
Doctypes
Doc types headers are necessary to have Struts pick up your xml configuration files. Even with the right name and location, it will not work without the right doctype. Beware of copying/pasting without it.
Accessing page context data in struts tags
Use #attr . This is usefull when you want to get values created by jstl or display tags. See this post. The Struts2 -> Displaytag -> Struts2 round tip can be done this way :
<s:set name="user" value="#session.user" scope="request" />
<display:table uid="profile" name="user.profiles" />
<s:property value="#attr.profile.label"/>
</display:table>







Leave a comment
Use your gravatar account to get your photo displayed with your comment.