web.xml的分发器代码:

<!-- 引入struts核心过滤器 -->
<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代码:


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="hello" extends="struts-default">
<action name="hello" class="action.HelloAction" method="execute">
<result name="success">/index.jsp</result> </action>
</package>
</struts>

常用的常量配置

<struts>

    <!-- 0. 请求数据编码 -->
<constant name="struts.i18n.encoding" value="UTF-8"/>
<!-- 1. 修改Struts默认的访问后缀 -->
<constant name="struts.action.extension" value="action,do,"></constant>
<!-- 2. 修改xml自动重新加载 -->
<constant name="struts.configuration.xml.reload" value="true"/>
<!-- 3. 开启动态方法调用 (默认不开启)-->
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<!-- 4. 修改上传文件的最大大小为30M -->
<constant name="struts.multipart.maxSize" value="31457280"/> </struts>

Struts2配置文件复用代码【web.xml、struts.xml、常量配置】的更多相关文章

  1. Struts2中有关struts-default.xml,struts.xml,struts.properties文件详解

    1) struts-default.xml 这个文件是struts2框架默认加载的配置文件.它定义struts2一些核心的bean和拦截器. <?xml version="1.0&qu ...

  2. 一 SSH整合:Spring整合Struts2的两种方式,struts.xml管理Action&Bean管理Action

    SSH回顾 1 引入jar包 Struts2的jar包 D:\Struts2\struts-2.3.35\apps\struts2-blank\WEB-INF\lib  开发基本包 Struts2有一 ...

  3. struts2.1.6教程二、struts.xml配置及例程

    1.配置文件的优先级 在struts2中一些配置(比如常量)可以同时在struts-default.xml(只读性),strtus-plguin.xml(只读性),struts.xml,struts. ...

  4. struts2学习笔记(3)struts.xml的一些常用设置

    在开发中通常需要用到多个配置文件,可以通过在web.xml中添加以下代码: <include file="login.xml"></include> 将sr ...

  5. struts2配置文件的加载顺序以及 struts.xml package 的配置说明

    查看StrutsPrepareAndExecuteFilter:(核心过滤器)两个功能 :预处理 和 执行 在预处理功能中 init 方法中会有加载配置文件的代码: dispatcher.init() ...

  6. struts2中struts.xml配置文件详解【未整理】

    1.    深入Struts2的配置文件 本部分主要介绍struts.xml的常用配置. 1.1.    包配置: Struts2框架中核心组件就是Action.拦截器等,Struts2框架使用包来管 ...

  7. struts2 的struts.xml配置详解

    在应用struts框架进行开发时,必不可少的一步就是对struts.xml进行配置,对于该文件了解越多,我们开发起一应用程序定会更加顺手.下面我们看一下struts.xml的内容,每一项都有什么作用. ...

  8. Struts2初学 Struts.xml详解二

    A.使用继承实现设置全局视图    package节点中还可以设置全局的视图,如:     <global-results>         <result name="e ...

  9. struts2核心配置之struts.xml

    struts.xml -常量配置 -包配置 -包含配置 一.常量配置 struts2常量的配置通常采用三种方式: 1.在struts.xml中使用<constant>元素配置常量 < ...

随机推荐

  1. Fiddler设置代理(PC和Android)

    Fiddler设置 打开Fiddler,进入Tools--->Fiddler Options,勾选以下信息:   OK,就配置完成了.   PC端设置: 以火狐为例,打开选项--->高级 ...

  2. 克隆一个centos虚拟机的环境配置

    克隆环境预处理设置 iptables -F  #清除规则 /etc/init.d/iptables save vim /etc/selinux/config selinux=disabled   # ...

  3. 【Centos】修改系统字符集

    centos7: vim /etc/locale.conf LANG=zh_CN.gb2312 其他版本linux: vim /etc/sysconfig/i18n

  4. 8.8.2 Final关键字

    final表示不可改变的含义   1.采用final 修饰的类不能被继承 2.采用final 修饰的方法不能被覆盖 3.采用final 修饰的变量不能被修改 4.final修饰的变量必须显示初始化(该 ...

  5. BotVS开发基础—2.11 API绘制图表

    代码 import time chart = { '__isStock': True, # 标记是否为一般图表,有兴趣的可以改成 false 运行看看. 'tooltip': {'xDateForma ...

  6. 斜率DP hdu 3507

    Problem Description Zero has an old printer that doesn't work well sometimes. As it is antique, he s ...

  7. spring文件上传

    Spring文件上传 1,导包: <dependency> <groupId>javax.servlet</groupId> <artifactId>s ...

  8. Python学习笔记3

    __slots__ 如果我们想要限制class的属性怎么办?比如,只允许对Student实例添加name和age属性. 为了达到限制的目的,Python允许在定义class的时候,定义一个特殊的__s ...

  9. 斐波那契数列—Java

    斐波那契数列想必大家都知道吧,如果不知道的话,我就再啰嗦一遍, 斐波那契数列为:1 2 3 5 8 13 ...,也就是除了第一项和第二项为1以外,对于第N项,有f(N)=f(N-1)+f(N-2). ...

  10. 函数作用域中的this问题

    首先一起回顾下预解析和作用域吧: 预解析: 浏览器每读到一个script标签或function,先不执行任何代码,会先把整个代码快速的浏览一遍,然后从中 挑出 var 和 function两个关键字 ...