Struts2 spring 多配置文件使用通配符
2012-01-21 18:28
405 查看
过年了但是并没有回家,策划着为公司搞一套完整的开发框架(UT),很久都没有搞程序了,显然觉得非常生疏了。把经验分享给大家
spring:
这个比较简单,因为spring的初衷即如此设计
<!--Spring-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml,classpath:*Context.xml,classpath:/*/*Context.xml</param-value>
</context-param>
Struts2:
这个就比较麻烦了,首先的从xwork说起,版本要在2.1以上,试了在web.xml中配,在试了几次准备放弃的时候在struts.xml中配置成功:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="false" />
<!-- 交给spring管理 -->
<constant name="struts.objectFactory" value="spring" />
<!--加载所有Struts2配置文件-->
<include file="*/struts.xml"/>
<package name="struts-ut" extends="struts-default">
</package>
</struts>
在贴一个在web.xml中指定struts2默认找配置文件的方法(前几天公司有个同事给我们上了一课,据说默认找的配置文件不能改)
<!--Struts2-->
<filter>
<filter-name>struts2</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,struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
spring:
这个比较简单,因为spring的初衷即如此设计
<!--Spring-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml,classpath:*Context.xml,classpath:/*/*Context.xml</param-value>
</context-param>
Struts2:
这个就比较麻烦了,首先的从xwork说起,版本要在2.1以上,试了在web.xml中配,在试了几次准备放弃的时候在struts.xml中配置成功:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="false" />
<!-- 交给spring管理 -->
<constant name="struts.objectFactory" value="spring" />
<!--加载所有Struts2配置文件-->
<include file="*/struts.xml"/>
<package name="struts-ut" extends="struts-default">
</package>
</struts>
在贴一个在web.xml中指定struts2默认找配置文件的方法(前几天公司有个同事给我们上了一课,据说默认找的配置文件不能改)
<!--Struts2-->
<filter>
<filter-name>struts2</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,struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
相关文章推荐
- Struts2 spring 多配置文件使用通配符
- 使用通配符完成struts2和spring多配置文件_悄悄俏俏
- Struts2配置文件中使用通配符
- Struts2配置文件中使用通配符
- struts2--配置文件通配符的使用
- Struts2配置文件中的通配符的使用
- Struts2使用通配符加载配置文件和通配符方法的底层实现学习
- Struts2配置文件通配符的使用
- Struts2为应用指定多个配置文件和动态方法调用以及通配符的使用方法
- struts2-配置文件中通配符的使用
- struts2--配置文件中使用通配符
- Struts2配置文件中使用通配符收藏method="{1}"
- xFire在使用Spring2.5,设定文件配置记述中需要注意的问题
- Spring配置文件<context:property-placeholder>标签使用漫谈
- Spring 中使用jasypt对配置文件(.properties)中密码加密
- spring cloud config server 使用本地配置文件报错
- springboot 使用spring.profiles.active 区分不同环境下配置文件
- RabbitMQ学习之spring配置文件rabbit标签的使用
- spring中使用配置文件实现AOP
- Spring Boot配置文件规则以及使用方法官方文档查找以及Spring项目的官方文档查找方法