下面介绍一些struts2常用的配置信息,注意这些配置都有合适的默认值,不是必须的。
属性struts.i18n.encoding:指定字符集编码,这个配置经常用到;
属性struts.action.extension:指定JSP哪些后缀请求是struts2的请求,常用配置
属性struts.devMode:当系统发生异常,在浏览器打印详细的错误消息,产品上线时间以设为false关闭
属性struts.enable.DynamicMethodInvocation:是否允许OGNL在JSP中直接调用java方法,不推荐使用
标签include: 项目大的话,通常都会写很多struts2配置文件,然后通过include标签将其它配置文件引进来,需要注意的是如果struts.xml文件放在 src根目录下,include的内容是支持通配符的,但是如果struts.xml文件放在其它位置就不能用通配符了,必须老老实实写路径,下面这个 include就是struts.xml放在conf目录后引用其它文件的方式。
- <?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>
-
-
- <include file="struts-default.xml" />
-
-
- <constant name="struts.i18n.encoding" value="UTF-8"></constant>
-
- <!--该属性指定需要Struts 2处理的请求后缀,该属性的默认值是action,即所有匹配*.action的请求都由Struts 2处理
- 如果用户需要制定多个请求后缀,则多个后缀之间以英文逗号隔开-->
- <constant name="struts.action.extension" value="action,do"></constant>
-
-
- <constant name="struts.serve.static.browserCache" value="false"></constant>
-
-
- <constant name="struts.configuration.xml.reload" value="true"></constant>
-
-
- <constant name="struts.devMode" value="true" />
-
-
- <constant name="struts.enable.DynamicMethodInvocation" value="true" />
-
-
- <constant name="struts.ui.theme" value="simple"></constant>
-
-
- <constant name="struts.objectFactory" value="spring"></constant>
-
-
- <constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>
-
-
- <package name="CommonPackage" extends="struts-default" namespace="/common">
- <action name="toLoginPage">
- <result>/Web/login/page/login.jsp</result>
- </action>
- </package>
-
- <include file="../conf/common/struts2/interceptor-common-exception.xml"></include>
- </struts>
邢台百姓网 http://www.jinshixun.com/ mx66
少儿美术培训 http://bianmin.jinshixun.com/5685.html mx66