Reputation: 1124
domain/Forum_show.action?pg=2&forum=java
How do I rewrite that to:
domain/forum/java/pg/2
Upvotes: 0
Views: 3322
Reputation: 19356
Both are good answers but you can use UrlRewritefilter. In this link there is an example of how to use in a Struts2 application.
Upvotes: 2
Reputation: 2421
You may want to check Struts REST Plugin, which purpose is to follow Ruby on Rails URL style (just as you want).
Upvotes: 2
Reputation: 11055
Use the URL structure you like right from the start. The ability to map to any URL structure is a feature of the Servlet API.
Also, you don't need to have an action extension (the .action part) in Struts2. In my opinion, creating bogus extensions never made sense.
Here are a few pages where I have talked about using Named Variable Pattern Matching in order to provide prettier URLs. I use this technique in all of my Struts2 apps and it yields much nicer URLs similar to your second example.
Upvotes: 4