I read the struts manual on wildcard mappings and decided to test some of the examples for myself. I have an action that points to:
<action name="**" method="getPerson" class="PersonActionBean">
<result>/person/view.jsp</result>
</action>
This allows me to go anywhere past /person and see the view.jsp as far as I can understand it. So what I’m trying to do now is go to /person/jack/black then I want the getPerson method inside PersonActionBean class to get the URL fields jack and black and do a search in my DB by name and surname then populate an object that will be used on view.jsp
My concern isn’t around the search functionality but around retrieving the fields in the URL from the method getPerson. How would I retrieve jack and black from the URL and use it in my getPerson method?
I’m using struts 2.1.8.1
Method 1 – With struts2-convention plugin
If you call
persons/jack/black, the params should be set toparam1 = jack,param2 = blackMethod 2 – Without struts2-convention plugin
References
Check out Advanced Wildcard