struts2是可以配置默认的后缀名的,如http://localhost:8080/test.action,这个是默认的,但是也可以通过配置去修改这个.action为别的。
这里是通过一个常量配置改变的。
1 |
<constant name="struts.action.extension" value="do"/> |
这样的就会变为http://localhost:8080/test.do来访问。
但是我很不喜欢有后缀,百度了很多大家的结论一般都是使用SmartUrls和urlrewritefilter这两个解决,但是我只是想把后缀去掉而已,就让我增加别的组件这个实在很不爽,最后终于找到了个方法:
1 |
<constant name="struts.action.extension" value=","/> |
在这里把value配置为,就可以使用http://localhost:8080/test完成访问了
有人问我是不是官方有说明,所以我把这段注释加上吧,大家可以看看
1 2 3 4 5 6 |
### Used by the DefaultActionMapper ### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do ### The blank extension allows you to match directory listings as well as pure action names ### without interfering with static resources, which can be specified as an empty string ### prior to a comma e.g. struts.action.extension=, or struts.action.extension=x,y,z,, struts.action.extension=action,, |
©原创文章,转载请注明来源: 赵伊凡's Blog
©本文链接地址: 关于struts2如何去掉默认的后缀(.action)
mark一下