Sunday, November 16, 2014

STRUTS2 Wildcard Congiguration in struts.xml file

Wildcard configuration in struts.xml file

<action name="*/*"  class="com.raj.rk.controller.{1}.{1}CTRL" method="{2}" >                                     
            <result name="create">/view/{1}/{1}Create.jsp</result>
            <result name="update">/view/{1}/{1}Update.jsp</result>                       
            <result name="view">/view/{1}/{1}View.jsp</result>
            <result name="list">/view/{1}/{1}Search.jsp</result>
</action>

Explanation

name = */*  
If the request comes for action policy/create.action, then the {1} will be policy and {2} will be create. so this both values will be mapped into the respected position in the action tag. and it will work accordingly.

Controller
In this policy/create call the controller called will be PolicyCTRL.java
and the method called will be create() inside the the PolicyCTRL.java class

Result
and the result file called will be /view/policy/PolicyCreate.jsp

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...