-->

User friendly URLs in struts2

2019-07-19 23:01发布

问题:

My project uses both struts1 and struts2 frameworks, I need to change the URLs user friendly. Is there any plugins to remove the .action and .do extension from the urls..?

Please attach the links of documentation along with the comments. Thanks In advance.

回答1:

You can change the action extension in struts 2 by adding

<constant name="struts.action.extension" value=".foo"/> 

to the struts.xml file (or the properties file etc.)

To remove it give an empty value.

<constant name="struts.action.extension" value=""/> 

Resources : http://struts.apache.org/release/2.0.x/docs/strutsproperties.html

But the extensions shouldn't worry you too much unless you are designing a website where users will access the web pages by URL.

For a normal web application I wouldn't worry about it.