Struts2 三、指定Struts2处理的请求后缀
来源:互联网 发布:python 爬虫金融数据 编辑:程序博客网 时间:2024/05/16 19:01
Action的请求通常情况下默认为以.action结尾,例如:http://localhost:9000/Struts2/hello/helloAction_sayHello.action .action就是这个请求的后缀,在Struts2中这个后缀是可以变更的,方法很简单,首先将Web.xml中的StrutsMapping改成如下代码:
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
然后在Struts.xml中添加一个常量:
<!-- 该属性用于指定Struts2请求处理的后缀,默认为.action 可以处理所有后缀是.action的处理,如果需要指定多个请求处理后缀,后缀之间用逗号隔开 --><constant name="struts.action.extension" value="do,action"></constant>
即可,如上代码,如果想实现请求中多个备用的后缀的话,在Value中将多个后缀以逗号分隔。
下面贴一下,Struts2中最常见的Struts2常量配置:
<!-- 指定默认 编码集,作用于HttpServletRequest 的setCharacterEncoding方法和freemarker velocity的输出 --><constant name="struts.118n.encoding" value="UTF-8"></constant><!-- 该属性用于指定Struts2请求处理的后缀,默认为.action 可以处理所有后缀是.action的处理,如果需要指定多个请求处理后缀,后缀之间用逗号隔开 --><constant name="struts.action.extension" value="do,action"></constant><!-- 设置浏览器是否缓存静态内容,默认值为true,开发环境下建议设置为false --><constant name="struts.serve.static.browserCache" value="false"></constant><!-- 当Struts 修改文件以后,是否重新加载该文件,默认为false,推荐开发环境下设置为true --><constant name="struts.configuration.xml.reload" value="true"></constant><!-- 开发模式下可以打印更详细的错误信息 --><constant name="struts.devMode" value="false"></constant><!-- 默认视图主题 --><constant name="struts.ui.theme" value="simple"></constant><!-- 与Spring集成是,指定有Spring创建Action对象 --><constant name="struts.objectFactory" value="spring"></constant>
</pre><pre>
<constant name="struts.enable.DynamicMethodInvocation" value="false"></constant><!-- 禁止调用动态方法 --><!-- 上传文件的大小限制 --><constant name="struts.multipart.maxSize" value="10701096"></constant>
0 0
- Struts2 三、指定Struts2处理的请求后缀
- 指定需要struts2处理的请求后缀
- 指定Struts2处理的请求后缀
- 指定需要struts2处理的请求后缀
- 指定Struts2处理的请求后缀
- 四、指定struts2处理请求的后缀
- struts2教程:7、指定Struts2处理的请求后缀
- struts2-7指定struts2处理的请求后缀
- 复习struts2之指定处理的请求后缀
- Struts2_指定Struts2处理的请求后缀、常用常量
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- struts2处理.do后缀的请求
- struts2中的依赖注入与指定处理请求后缀
- Struts2 指定需要Struts 2处理的请求后缀-定义常量
- 传智Struts2笔记(6)指定需要Struts 2处理的请求后缀
- 学习maven的使用(maven在eclipse中的使用)(一)
- C++学习-引用作为函数参数
- 我的vim配置
- mysql 数据表读锁机制详解
- 禁止win7/win8自动更新到win10
- Struts2 三、指定Struts2处理的请求后缀
- Android设置TextView文字居中
- SVN(VisualSVN )详细教程(五)--下载和搭建SVN服务器
- 反渗透设备:纯净水处理设备的特点
- /dev/mtd和/dev/mtdblock的区别
- php学习基础篇之常量、文件上传
- 【Android应用开发技术:网络通信】计算机网络基础
- 【J2EE】--让你不能拒绝的J2EE13核心规范
- 关于编译出现 bash:adduser:command not found