struts2 基礎(chǔ)
- action extends ActionSupport abstract class, because it already provide some default operation(input, createErrorMessage).
- property is set by reflect to action, and pass to jsp(jsp is filled with these properties, jsp is a servlet, what it returned to user is HTML file)
- static validate happened in action method(override ActionSupport method), dynamic validation happened in action layer.
- change dynamic property file value in this way : thankyou=Thank you for registerling %{personBean.firstName}, Resource file can be deployed in action layer, package layer and global layer
- exception can be configured in bellow way: <global-exception-mappings>
<exception-mapping exception="org.apache.struts.register.exceptions.SecurityBreachException" result="securityerror" />
<exception-mapping exception="java.lang.Exception" result="error" />
</global-exception-mappings>
<global-results>
<result name="securityerror">/securityerror.jsp</result>
<result name="error">/error.jsp</result>
</global-results> - Wildcard Method Selection: flexible but not useful(<action name="*Person" class="org.apache.struts.tutorials.wildcardmethod.action.PersonAction" method="{1}">)
- integrate spring & struts 2 way: use spring plugin, main point is who to maintain action creation(spring || action), better choice is spring, you can enjoy great function of spring.
- Add Convention Plugin to so that you can use annotation
- intercepter can be configured in action level and package level.
posted on 2011-03-29 12:07 Sheldon Sun 閱讀(243) 評論(0) 編輯 收藏