struts2_5_struts中常量的配置

常量有两种配置方式:

1)在struts.xml中配置:(建议使用此种配置方式)

<struts>
  <constant name=”struts.action.extension” value=”action”/>
<struts>

2)在struts.properties中配置常量:

  truts.action.extension = action

因为常量可以在下面多配置文件中进行定义,所以我们需要了解struts2加载常量的搜索顺序:

struts-default.xml

struts-plugin.xml

struts.xml

struts.properties

web.xml

如果在多个文件中配置了同一个常量,则后一个文件中配置的常量值会覆盖前面文件中配置的常量值。

常用的常量介绍:

1)指定编码集:

<constant name=”struts.i18n.encoding” value=”UTF-8”>

2)指定struts2请求处理的后缀:

该属性的默认值是Action,即所有匹配“*.action”的请求都由Struts2处理,如果需要指定多个后缀,则多个后缀之间用逗号”,“分隔开

<span style="font-size:12px;"><constant name=”struts.action.extension” value=”do,action”/></span>

3)xml文件自动重新加载:

该文件当struts被文件修改后,系统会自动重新加载该文件,默认值为false,开发阶段最好设置为true

<span style="font-size:12px;"><constant name=”struts.configuration.xml.reload” value=”true”/></span>

4)打印错误信息的常量:

次常量在开发模式下使用,会打印出更详细的错误信息

<constant name=”strus.devMode” value=”true”/>

5)struts支持动态属性:

该属性设置struts是否支持动态属性,该属性的默认值是true,关闭该属性时可以设置为false

<constant name=”struts.enable.DynamicMethodInvocation” value=”false”/>

6)管理上传文件大小的常量:

该属性可以设置上传文件的大小

<constant name="struts.multipart.maxSize" value="1000000"/>










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值