`

利用struts.properties文件配置Struts2默认属性

阅读更多
在Struts2的核心包(struts2-core-2.0.11.2.jar)里面有一个名为 default.properties的文件
(具体路径是org.apache.struts2.default.properties)
其中包含了Struts2框架的一些“默认”配置属性。

如果我们要更改这些Struts2的默认属性,则可以通过以下方法:
方法一:
    我们可以在struts.xml文件中利用<constant>元素来更改default.properties文件中的默认配置。
    例如:
        <!-- 设置上传文件的临时目录 -->
        <constant name="struts.multipart.saveDir" value="c:\temp"></constant>

方法二:(推荐)
    我们也可以再“WEB-INF/classes”路径下建立一个名为“struts.properties文件”
    用来重新设置default.properties中默认配置。
    例如:
        struts.multipart.saveDir=c:\temp


我们推荐采用“方法二”,因为这样可以将struts2的Action配置 和 properties配置进行分离开来。

想象一下如果采用“方法一”,那么在struts.xml中除了要配置 “Action, Result, 拦截器”以外
还要再加上“框架属性”的配置~~~ 那岂不是很混乱么~~

有关 struts.xml和struts.properties 介绍

请详见:

http://hi.baidu.com/matrix286/blog/item/14ed76eb746ec5dad439c960.html
分享到:
评论

相关推荐

    Struts课堂笔记.rar--struts2的struts.properties配置文件详解

    加载附加的国际化属性文件(不包含.properties后缀) struts.custom.properties Location of additional configuration properties files to load 加载附加的配置文件的位置 struts.devMode Whether Struts ...

    Struts2属性文件详解

    该属性指定Struts 2应用加载用户自定义的属性文件,该自定义属性文件指定的属性不会覆盖struts.properties文件中指定的属性.如果需要加载多个自定义属性文件,多个自定义属性文件的文件名以英文逗号(,)隔开. struts....

    struts2的rest风格插件实例

    通过 struts.xml、struts.properties 或 web.xml 改变 struts.convention.default.parent.package 常量的值,让支持 REST 风格的 Action 所在的包默认继承 rest-default,而不是继承默认的 convention-default 父包...

    Struts2\constant应用

    该属性指定Struts 2框架默认加载的配置文件,如果需要指定默认加载多个配置文件,则多个配置文件的文件名之间以英文逗号(,)隔开。 该属性的默认值为struts-default.xml,struts-plugin.xml,struts.xml,看到该属性...

    Struts2入门教程(全新完整版)

    3.初识struts2配置文件 4 (1).web.xml文件 4 (2).struts.xml文件 4 (3).struts.properties(参default.properties) 4 (4)struts-default.xml 4 (5)其它配置文件 4 4.让MyEclipse提示xml信息 4 5.如何...

    struts2的单个文件上传

    本文主要两种方式,一:通过 FileUtils.copyFile(file, savefile);方法复制;二:通过字节流方式复制 ; web.xml struts.xml, struts.properties, UploadAction.java, index.jsp. success.jsp

    Struts 2中的constant配置详解

    通过对这些属性的配置,可以改变Struts 2 框架的一些默认行为,这些配置可以在struts.xml文件中完成,也可以在struts.properties文件中完成

    struts2核心属性文件

    struts2核心属性文件:默认的属性参数

    Myeclipse开发struts+hibernate+spring新手入门--环境配置---项目开发示例

    3、配置struts-config.xml文件;建立action、formbean; 改配置可以自动生成,使用eclipse进行自动生成,在建立时,如下图,可直接生成对应的action类和formbean类。 1 2 &lt;!DOCTYPE struts-config PUBLIC "-//...

    产品销售分析系统spring struts2 jfreechart ibatis

    修改工程中admanager/src/init.properties文件: datasource.url=jdbc:mysql://127.0.0.1:3306/product?useUnicode=true&characterEncoding=UTF-8 datasource.username=root datasource.password=111111 注:根据读者...

    【毕业设计】基于SSH(Struts2+Spring+Hibernate)搭建的失物招领平台(前后端源码+SQL脚本).zip

    【毕业设计】基于SSH(Struts2+Spring+Hibernate)搭建的失物招领平台(前后端源码+SQL脚本).zip LostFound失物招领网,本意是打算为我们学校长沙理工大学而做,就是一个有关失物招领的交流平台。 项目用到的相关...

    公文传输系统velocity struts spring hibernate(lib太大只发截图自己去下)

    1.2.1 查找并打开GWCS/WebRoot/WEB-INF/velocity.properties文件。 1.2.2 修改字符集配置 input.encoding = GBK output.encoding = GBK 1.2.3 保存修改文件。 2 发布运行 Tomcat服务器默认安装后使用8080端口,...

    jakarta-tomcat-connectors-jk2.0.4-win32-IIS.zip

    1、配置环境变量 JAVA_HOME 和 TOMCAT_HOME 2、将 isapi_redirector2.dll 文件拷贝到 TOMCAT_HOME 中的任意一个目录中,如:... 7、拷贝 jk2.properties 、 workers2.properties 两个文件到 TOMCAT_HOME/conf 目录中

    BOS 技术整理

    rc/main/resource 提供 config.properties 外部属性文件、log4j.properties 日志配置文件 配置文件如下: applicationContext.xml  struts2 注解 类上 @ParentPackage 包继承谁? extends=”struts-default...

    (2.0版本)自己写的struts2+hibernate+spring实例

    数据库连接配置文件是/s2sh/src/目录下面的jdbc.properties文件.直接配置即可. &lt;br&gt;以下是一些相关说明. &lt;br&gt; 数据库脚本 create table HUBO_USER ( ID VARCHAR2(32) not null, NAME VARCHAR...

    产品销售分析系统案例

    修改工程中admanager/src/init.properties文件: datasource.url=jdbc:mysql://127.0.0.1:3306/product?useUnicode=true&characterEncoding=UTF-8 datasource.username=root datasource.password=111111 注:根据读者...

    struts2+spring+hibernate开发游戏买卖网站源码_mysql

    1、使用技术 struts2 + hibernate + spring + dwr 2、开发环境 tomcat6.0 + jdk1.5 + eclipse + MySQL5.0 3、根据你的需要开放自主交易和寄售交易 4、在线订单即时提醒,让你更快,更准确的发货 5、整合易宝最新...

    struts2+hibernate3+spring2.5的完整框架

    此源码是struts2+hibernate3+spring2.5的完整框架,可用于测试和基本的简单开发 请在WEB-INF/deploy.properties修改数据源。默认采用mysql数据库

    spring chm文档

    13.11.2. 对模型的支持:ModelMap (ModelAndView) 13.11.3. 对视图的支持: RequestToViewNameTranslator 13.12. 其它资源 14. 集成视图技术 14.1. 简介 14.2. JSP和JSTL 14.2.1. 视图解析器 14.2.2. 'Plain-...

    OA项目SSH整合框架

    一,集成 Spring 与 Hibernate 1,配置SessionFactory 1,配置 ---------------------- applicationContext.xml ------------------------ ... 2,在struts.xml中配置action时,在class属性中写bean的名称

Global site tag (gtag.js) - Google Analytics