I have many destinations (say 150+) and each destination has 2 different variants:
- A
- B
I have generated a html for each of these variants. For e.g.:
- NewYork-A.html
- NewYork-B.html
- SanFrancisco-A.html
- SanFrancisco-B.html
- LasVegas-A.html
- LasVegas-B.html
…
generic format being:
- Destination-A.html
- Destination-B.html
each of these files are written to /seo/Destination/
How can I map a given URL to these files in struts 2:
www.mysite.com/NewYork-Tourism => http://www.mysite.com/seo/Destinations/NewYork-A.html AND
www.mysite.com/NewYork-Travel => http://www.mysite.com/seo/Destinations/NewYork-B.html
Generic:
www.mysite.com/Destination-Tourism => http://www.mysite.com/seo/Destinations/Destination-A.html
AND
www.mysite.com/Destination-Travel => http://www.mysite.com/seo/Destinations/Destination-B.html
One way I can think of doing this is generating as many actions as (destination * variant_types) and then map the result of each of those to the proper html files. Something like this:
<action name="NewYork-Tourism">
<result name="success">/seo//Destination/NewYork-A.html</result>
</action>
<action name="NewYork-Travel">
<result name="success">/seo//Destination/NewYork-B.html</result>
</action>
.. and so on
Is there any other (better) way to do this ?
One qquick way which seems to me is to make use of Wildcard Mapping,Struts2 has a way namely Wildcard which seems more suitable to you.
something like
For more details please refer to the documents