zoukankan      html  css  js  c++  java
  • Struts2 三、指定Struts2处理的请求后缀

    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>



  • 相关阅读:
    linux定时任务crontab介绍
    kafka跨集群同步方案
    hadoop配置参数速查大全
    kafka生产者消费者示例代码
    storysnail的Linux串口编程笔记
    storysnail的Windows串口编程笔记
    botbrew下写glib2程序
    codeblocks配置GLUT
    使用Code::blocks在windows下写网络程序
    使用pango-Cairo列出系统中的有效字体
  • 原文地址:https://www.cnblogs.com/raphael5200/p/5114799.html
Copyright © 2011-2022 走看看