struts2不显示.do .action 后缀

struts2是可以配置默认的后缀名的,如http://localhost:8080/test.action,这个是默认的,但是也可以通过配置去修改这个.action为别的。

这里是通过一个常量配置改变的。

  1. <constant name="struts.action.extension" value="do"/>  
但是我很不喜欢有后缀,百度了很多大家的结论一般都是使SmartUrls和urlrewritefilter这两个解决,但是我只是想把后缀去掉而已,就让我增加别的组件这个实在很不爽,最后终于找到了个方法:
<constant name="struts.action.extension" value=","/> 
在这里把value配置为,就可以使用http://localhost:8080/test完成访问了


在struts2的默认常量配置文件中(default.properties,在struts-core-2.3.x.jar的org.apache.struts2下),有这么一段内容
### 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,,

这个不建议酱紫做。
因为上传下载可能会被拦截
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值