如何在struts动作中更改url模式 [英] how to change url pattern in struts action
问题描述
domain/Forum_show.action?pg=2&forum=java
如何将其重写为:
domain/forum/java/pg/2
推荐答案
从一开始就使用您喜欢的URL结构.映射到任何URL结构的功能是Servlet API的功能.
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.
此外,您在Struts2中不需要动作扩展(.action部分).我认为,创建虚假扩展名没有道理.
Also, you don't need to have an action extension (the .action part) in Struts2. In my opinion, creating bogus extensions never made sense.
以下是我讨论过使用命名变量模式匹配以提供更漂亮的URL的几页.我在所有的Struts2应用程序中都使用了这种技术,它产生的URL更好,类似于您的第二个示例.
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.
- NamedVariablePatternMatcher
- Better URLs with Struts2
这篇关于如何在struts动作中更改url模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!