---
title: "《研磨struts2》A.2 struts.properties的配置 之 A.2.1 概述  "
author: "研磨struts2"
date: "2012-07-09T12:10:59Z"
tags: []
categories: ["企业架构"]
slug: "struts2-a-2-struts-properties-a-2-1"
draft: false
lastmod: "2012-07-09T12:10:59Z"
id: 1582446
url: "https://rubbing-struts2.iteye.com/blog/1582446"
---

### A.2.1  概述

       如果我们希望覆盖在default.properties文件里面定义的默认配置，那就可以定义struts.properties文件，在里面设置我们需要的值，当然现在也可以在struts.xml中配置&lt;constant&gt;元素来实现同样的功能。

       如果配置struts.properties文件，需要把它放置到当前的classpath下面，如果用Eclipse开发，把这个文件放到src下面就可以，会自动编译到classes下面。

       struts.properties文件内的格式是“key=value”，一行一对的进行配置。

### []()A.2.2  具体的参数描述

**1：struts.configuration**

       **含义：**用来指定一个用来读取默认配置的类，这个类需要继承org.apache.struts2.config.Configuration

       **默认值：**org.apache.struts2.config.DefaultConfiguration

**2：struts.locale**

       **含义：**用来设置默认的locale

       **默认值：**en\_US

**3：struts.i18n.encoding**

       **含义：**用来设置默认的编码方式

       **默认值：**UTF-8

**4：struts.objectFactory**

       **含义：**用来设置默认的对象工厂

       **默认值：**spring

**5：struts.objectFactory.spring.autoWire**

       **含义：**如果使用spring作为默认的对象工厂，这里就配置spring的自动装配策略

       **默认值：**name

**6：struts.objectFactory.spring.useClassCache**

       **含义：**配置当struts和spring集成时，是否缓存类实例

       **默认值：**true

**7：struts.objectFactory.spring.autoWire.alwaysRespect**

       **含义：**总是使用spring的自动装配策略

       **默认值：**false

**8：struts.objectTypeDeterminer**

       **含义：**对象类型确定器。

       **默认值：**tiger

**9：struts.multipart.parser**

       **含义：**指定进行multipart上传的解释器，也就是如何处理文件上传。

       **默认值：**jakarta

**10：struts.multipart.saveDir**

       **含义：**指定进行multipart上传的临时文件存放路径。

       **默认值：**没有指定

**11：struts.multipart.maxSize**

       **含义：**指定进行multipart上传的临时文件的最大限制。

       **默认值：**2097152

**12：struts.custom.properties**

       **含义：**用户自定义属性文件的路径，不能是struts.properties。

       **默认值：**application,org/apache/struts2/extension/custom

**13：struts.mapper.class**

       **含义：**设置如何把url和类进行对应。

       **默认值：**org.apache.struts2.dispatcher.mapper.DefaultActionMapper

**14：struts.action.extension**

       **含义：**指定需要Struts2处理的后缀列表，多个名字间用逗号分隔。

       **默认值：**action,,

**15：struts.serve.static**

       **含义：**表示struts是否应该提供其jar文件内部的静态内容。

       **默认值：**true

**16：struts.serve.static.browserCache**

       **含义：**是否缓存静态资源。

       **默认值：**true

**17：struts.enable.DynamicMethodInvocation**

       **含义：**是否启用动态方法调用的功能。

       **默认值：**true

**18：struts.enable.SlashesInActionNames**

       **含义：**是否可以在action的名称里面使用“/”。

       **默认值：**false

**19：struts.tag.altSyntax**

       **含义：**是否可以使用“%{…}”格式的表达式。

       **默认值：**true

**20：struts.devMode**

       **含义：**是否启用开发模式。

       **默认值：**false

**21：struts.i18n.reload**

       **含义：**是否启用i18n自动重载。

       **默认值：**false

**22：struts.ui.theme**

       **含义：**默认的主题

       **默认值：**xhtml

**23：struts.ui.templateDir**

       **含义：**模板的默认存放路径

       **默认值：**template

**24：struts.ui.templateSuffix**

       **含义：**模板的默认类型，可以是ftl(FreeMarker)、vm(Velocity)、jsp(JSP)

       **默认值：**ftl

**25：struts.configuration.xml.reload**

       **含义：**指定是否在struts.xml文件被修改后重新加载它

       **默认值：**false

**26：struts.velocity.configfile**

       **含义：**指定默认的Velocity配置文件

       **默认值：**velocity.properties

**27：struts.velocity.contexts**

       **含义：**指定默认的Velocity Context的配置文件列表，用逗号分隔

       **默认值：**没有指定

**28：struts.velocity.toolboxlocation**

       **含义：**指定Velocity工具箱的存放位置

       **默认值：**没有指定

**29：struts.url.http.port**

       **含义：**指定默认的http端口号

       **默认值：**80

**30：struts.url.https.port**

       **含义：**指定默认的https端口号

       **默认值：**443

**31：struts.url.includeParams**

       **含义：**指定Struts 2生成URL时是否包含请求参数

       **默认值：**none

**32：struts.custom.i18n.resources**

       **含义：**指定自定义的i18n资源包的名称

       **默认值：**testmessages,testmessages2

**33：struts.dispatcher.parametersWorkaround**

       **含义：**指定为不支持HttpServlet Request调用getParameterMap()方法的应用程序提供其他方式的支持

       **默认值：**false

**34：struts.freemarker.manager.classname**

       **含义：**指定使用哪一种FreeMarker Manager类。

       **默认值：**org.apache.struts2.views.freemarker.FreemarkerManager

**35：struts.freemarker.templatesCache**

       **含义：**指定是否对FreeMarker的模板进行缓存。

       **默认值：**false

**36：struts.freemarker.beanwrapperCache**

       **含义：**指定是否启用BeanWrapper的模型缓存。

       **默认值：**false

**37：struts.freemarker.mru.max.strong.size**

       **含义：**指定Freemaker中MruCacheStorage的maxStrongSize。

       **默认值：**100

**38：struts.xslt.nocache**

       **含义：**是否使用样式表缓存。

       **默认值：**false

**39：struts.mapper.alwaysSelectFullNamespace**

       **含义：**是否允许把最后一个反斜线之前的所有东西作为一个完整的命名空间。

       **默认值：**false

**40：struts.ognl.allowStaticMethodAccess**

       **含义：**是否允许在OGNL表达式中访问静态方法。

       **默认值：**false

**41：struts.el.throwExceptionOnFailure**

       **含义：**设置在处理el表达式的时候，是否可以抛出运行时错误。

       **默认值：**false

**42：struts.ognl.logMissingProperties**

       **含义：**设置是否记录缺失属性日志。

       **默认值：**false

**43：struts.ognl.enableExpressionCache**

       **含义：**设置设置是否缓存解析过的OGNL表达式。

       **默认值：**true

# 参考书目

1、Struts2在线文档，http://struts.apache.org/2.2.1.1/docs/guides.html。

       2、《Struts2实战》，作者：（美）布朗，（美）戴维斯，斯坦利克著，马召等译，人民邮电出版社

       3、《精通Struts2：Web2.0开发实战》，（澳）拉夫利（Roughley,I.）著，李进华等译，人民邮电出版社

       4、《深入浅出Struts2》，（加）库尼亚瓦（Kurniawan，B.）著，杨涛等译，人民邮电出版社

 

私塾在线网站原创《[研磨struts2](http://sishuok.com/forum/blogCategory/showByCategory.html?categories_id=81&user_id=5948)》系列

转自请注明出处：【[http://sishuok.com/forum/blogPost/list/0/4197.html](http://sishuok.com/forum/blogPost/list/0/4197.html)】

欢迎访问[http://sishuok.com](http://sishuok.com/)获取更多内容