在轻量级企业应用开发中,ssh开发绝对是主流,因为它只需要几个数据包就可以完成很强大的功能.但是随之而来的问题是,如何管理它们的配置文件呢?众所周知的是,struts默认只有一个配置文件,但是假如你的action过多,你的配置文件也会大大增加.还有hibernate的配置文件,共分为两种,主要的配置文件和映射文件.spring的配置文件较少,只有一个.
这里建议将配置文件分开管理,这样方便团队合作.因为有可能你的修改影响到其他人.具体请看下面.



然后修改各配置文件的内容.
这是该filter过滤器的配置.
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,struts2/struts.xml</param-value>
</init-param>
</filter>
这里是改spring的配置文件的读取路径
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext.xml</param-value>
</context-param>
这是改applicationContext读取数据源的位置.
<bean name="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocations">
<list>
<value>
classpath:hibernate/cfg/hibernate.cfg.xml
</value>
</list>
</property>
</bean>
这样各个配置就配好了.以后要加直接到对应的目录里加就行了
该贴被lusxingbao编辑于2013-3-21 13:31:46