Customizing controller
While reading Struts2 documentation, I encountered the passage as quoted below
customizing controller - Struts 1 lets to customize the request processor per module, Struts 2 lets to customize the request handling per action, if desired.
What do the author exactly mean. Sim开发者_C百科ple examples in code form for the demonstration on both will be appreciated
Thanks in advance
Daniel
Example of customizing the request processor in Struts 1:
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"/>
This replaces the default Struts request processor with a Spring one, which matches mapped Struts actions with beans in the Spring context to perform dependency injection.
Example of delegating action handling in Struts 1:
<action-mappings>
<action path="/welcome" forward="/WEB-INF/pages/welcome.htm"/>
<action path="/searchEntry" forward="/WEB-INF/pages/search.jsp"/>
<action path="/searchSubmit"
type="org.springframework.web.struts.DelegatingActionProxy"
input="/searchEntry.do"
validate="true"
name="searchForm">
<forward name="success" path="/WEB-INF/pages/detail.jsp"/>
<forward name="failure" path="/WEB-INF/pages/search.jsp"/>
</action>
Here the action type is replaced with a Spring proxy class, which looks up a matching bean (by path) in the Spring context. The purpose of this is also to inject dependencies in Struts 1 actions. It is just another approach, giving more control to Spring.
I don't know how things work in Struts 2.
精彩评论