struts2参考之struts.properties

本文详细介绍了Struts2核心配置文件struts.properties的各项参数及其作用,包括配置管理器、国际化设置、对象工厂、文件上传等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

struts.properties

struts.properties是Struts 2非常重要的一个文件,下面分别介绍其中一些参数的作用。

指定加载Struts 2配置文件管理器,默认为org.apache.struts2.config.DefaultConfiguration。

 
  1. #struts.configuration=org.apache.struts2.config.DefaultConfiguration

设置默认的locale和字符编码。

 
  1. #struts.locale=en_US
  2. struts.i18n.encoding=UTF- 8

指定Struts的工厂类。

 
  1. #struts.objectFactory=spring

指定Spring框架的装配模式。

 
  1. struts.objectFactory.spring.autoWire=name

该属性指定整合Spring时,是否对Bean进行缓存,值为true或false,默认为true。

 
  1. struts.objectFactory.spring.useClassCache= true

指定类型检查:

 
  1. #struts.objectTypeDeterminer=tiger
  2. #struts.objectTypeDeterminer=notiger

该属性指定处理 MIME类型multipart/form-data,文件上传。

 
  1. #struts.multipart.parser=cos
  2. #struts.multipart.parser=pell
  3. struts.multipart.parser=jakarta

指定上传文件时的临时目录,默认使用 javax.servlet.context.tempdir。

 
  1. struts.multipart.saveDir=
  2. struts.multipart.maxSize= 2097152

加载自定义属性文件。

 
  1. #struts.custom.properties=application,
    org/apache/struts2/extension/custom

指定请求URL与Action映射器,默认为org.apache.struts2.dispatcher.mapper.Default

 
  1. ActionMapper。
  2. #struts.mapper. class =org.apache.struts2.
    dispatcher.mapper.DefaultActionMapper

指定Action的后缀,默认为action。

 
  1. struts.action.extension=action

指定浏览器是否缓存静态内容,测试阶段设置为false,发布阶段设置为true。

 
  1. struts.serve. static .browserCache= true

设置是否支持动态方法调用,true为支持,false不支持。

 
  1. struts.enable.DynamicMethodInvocation= true

设置是否可以在Action中使用斜线,默认为false不可以,想使用需设置为true。

 
  1. struts.enable.SlashesInActionNames= false

是否允许使用表达式语法,默认为true。

 
  1. struts.tag.altSyntax= true

设置当struts.xml文件改动时,是否重新加载。

 
  1. struts.configuration.xml.reload= true

设置Struts是否为开发模式,默认为false,测试阶段一般设为true。

 
  1. struts.devMode= false

设置是否每次请求都重新加载资源文件,默认为false。

 
  1. struts.i18n.reload= false

标准的UI主题,默认的UI主题为xhtml,可以为simplexhtml或ajax。

 
  1. struts.ui.theme=xhtml

模板目录。

 
  1. struts.ui.templateDir=template

设置模板类型,可以为 ftl、vm、jsp。

 
  1. struts.ui.templateSuffix=ftl

定位velocity.properties 文件,默认为velocity.properties。

 
  1. struts.velocity.configfile=velocity.properties

设置Velocity的Context。

 
  1. struts.velocity.contexts=

定位ToolBox。

 
  1. struts.velocity.toolboxlocation=

指定Web应用的端口。

 
  1. struts.url.http.port= 80

指定加密端口。

 
  1. struts.url.https.port= 443

设置生成URL时是否包含参数,值可以为none、get或all。

 
  1. struts.url.includeParams=get

设置要加载的国际化资源文件,以逗号分隔。

 
  1. #struts.custom.i18n.resources=testmessages,testmessages2

对于一些Web应用服务器不能处理HttpServletRequest.getParameterMap(),像 WebLogic、Orion和OC4J等,需设置成true,默认为false。

 
  1. struts.dispatcher.parametersWorkaround= false

指定FreeMarker管理器。

#struts.freemarker.manager.classname=org.apache.struts2.views.freemarker.FreemarkerManager

设置是否对FreeMarker模板设置缓存,效果相当于把Template复制到WEB_APP/templates。

 
  1. struts.freemarker.templatesCache= false

通常不需要修改此属性。

 
  1. struts.freemarker.wrapper.altMap= true

指定样式表是否使用缓存,开发阶段设为true,发布阶段设为false。

 
  1. struts.xslt.nocache= false

设置Struts自动加载的文件列表。

 
  1. struts.configuration.files=struts- default .xml,
    struts-plugin.xml,struts.xml

设置是否选择最后一个斜杠前的namespace。

 
  1. struts.mapper.alwaysSelectFullNamespace= false
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值