Shabarinath Volam
Shabarinath Volam

Reputation: 747

Getting exception while passing specific parameters in struts2 xml

Hi i am working on struts2, I am facing problem while passing specific parameters. My xml for controller is like below

<action name="summary/*/*" class="UserController" method="summary">
            <result>/view/user/Summary.jsp</result>
            <param name="type">{1}</param>
            <param name="user.loginName">{2}</param>
            <interceptor-ref name="caspianDefaultStack" />  
        </action>

If i pass url like summary/profile/jhon It work fine but when i pass url like summary/profile/jhon.mickel (If second parameter contains ".") the method summary is not called why it is behaving in a strange way and how can i resolve this??

Upvotes: 1

Views: 178

Answers (1)

coding_idiot
coding_idiot

Reputation: 13734

Use regex to directly map the params in the wild-cards mapping. Something like this :

<action name="summary/{type}/{user.loginName}" class="UserController" method="summary">
            <result>/view/user/Summary.jsp</result>
            <interceptor-ref name="caspianDefaultStack" />  
        </action>

If that still doesn't work, then use {FIELD_NAME:REGEX} format. See the docs for example.

Upvotes: 2

Related Questions