how to change url pattern in struts action

跟風遠走 提交于 2019-12-02 07:34:03
Steven Benitez

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.

You may want to check Struts REST Plugin, which purpose is to follow Ruby on Rails URL style (just as you want).

Both are good answers but you can use UrlRewritefilter. In this link there is an example of how to use in a Struts2 application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!