XML文件的相关配置

来源:互联网 发布:gta5低配优化补丁3dm 编辑:程序博客网 时间:2024/05/20 00:48

applicationContext.xml文件的配置

<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"><bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName"value="oracle.jdbc.driver.OracleDriver"></property><property name="url"value="jdbc:oracle:thin:localhost:1521:orcl"></property><property name="username" value="demo"></property><property name="password" value="ccce"></property></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource"><ref bean="dataSource" /></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop></props></property><property name="mappingResources"><list><value>com/pojo/Storage.hbm.xml</value><value>com/pojo/Orders.hbm.xml</value><value>com/pojo/OrdersLine.hbm.xml</value></property></bean><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory"><ref bean="sessionFactory"/></property></bean><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED"/><tx:method name="delete*" propagation="REQUIRED"/><tx:method name="update*" propagation="REQUIRED"/><tx:method name="find*" propagation="NOT_SUPPORTED" read-only="true"/><tx:method name="get*" propagation="NOT_SUPPORTED" read-only="true"/><tx:method name="*" propagation="REQUIRED"/></tx:attributes></tx:advice><aop:config><aop:pointcut expression="execution(public * com.service.impl.*.*(..))" id="pc"/><aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/></aop:config><bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"><property name="sessionFactory"><ref bean="sessionFactory"/></property></bean><bean id="commonDao" class="com.dao.impl.CommonDaoImpl"><property name="hibernateTemplate"><ref bean="hibernateTemplate"/></property></bean><bean id="sachDao" class="com.service.impl.SaleService"><property name="saleCDao"><ref bean="commonDao"/></property><property name="salePlanDao"><ref bean="commonDao"/></property><property name="saleUserDao"><ref bean="commonDao"/></property></bean><!-- 权限管理 --><bean id="userDao" class="com.service.impl.UserService"><property name="userDao"><ref bean="commonDao"/></property></bean><bean id="rightDao" class="com.service.impl.RightServiceImpl"><property name="rightDao"><ref bean="commonDao"/></property><property name="roleDao"><ref bean="commonDao"/></property></bean><!-- 用户全限 --><bean id="userActionDao" class="com.action.UserAction" scope="prototype"><property name="userDao"><ref bean="userDao"/></property><property name="righService"><ref bean="rightDao"/></property></bean><bean id="roleActionDao" class="com.action.RoleAction" scope="prototype"><property name="rightService"><ref bean="rightDao"/></property></bean><bean id="ordeActionDao" class="com.action.OrderAction" scope="prototype"><property name="orderDao"><ref bean="ordServiceDao"/></property></bean><bean id="ServiceActionDao" class="com.action.ServiceAction" scope="prototype"><property name="managerService"><ref bean="ServManageDao"/></property></bean></beans>
<?xml version="1.0" encoding="UTF-8" ?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"    default-autowire="byName" default-lazy-init="true">        <!-- 说明:下面有的Bean配置提供了多种方案,请根据需要采用某一种(别忘了注释掉其他同类方案) --><!-- 自动扫描Spring注解配置  并保证@Required,@Autowired的属性被注入--><context:component-scan base-package="com.xmm" /><!-- 自动加载属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties" /><!-- 配置数据源:方法一,使用C3P0方式(推荐) --><!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  --><!-- destroy-method="close"  --><!-- p:driverClass="${jdbc.driverClassName}" --><!-- p:jdbcUrl="${jdbc.url}"  --><!-- p:user="${jdbc.username}"  --><!-- p:password="${jdbc.password}" /> --><!-- <context:property-placeholder location="classpath:jdbc.properties"/> -->      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">         <property name="driverClassName" value="${jdbc.driverClassName}"/>         <property name="url" value="${jdbc.url}"/>         <property name="username" value="${jdbc.username}"/>         <!-- property池启动时的初始值  -->          <property  name="password" value="${jdbc.password}"/>          <!-- 连接name="initialSize" value="${initialSize}"/>-->          <property name="initialSize" value="1"/>          <!-- 连接池的最大值 -->          <property name="maxActive" value="500"/>          <!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 -->          <property name="maxIdle" value="2"/>          <!--  最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 -->          <property name="minIdle" value="1"/>      </bean>  <!-- 配置数据源:方法二,使用DBCP方式(不推荐) --><!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}" /> --><!-- 配置数据源:方法三,使用JNDI方式 --><!-- <jee:jndi-lookup id="dataSource" jndi-name="${jndi.name}" /> --> <!-- 配置Hibernate的数据源代理工厂:方法一,使用p属性通配符,按文件名搜索匹配的映射文件 --><bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"p:dataSource-ref="dataSource" ><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.format_sql">${hibernate.format_sql}</prop><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop><prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop><prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop><prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop></props></property><!-- 加载hibernate的jpa注解形式实体 --><property name="packagesToScan"><list><value>com.xmm.demo.domain*</value></list></property></bean><!-- 配置Hibernate的数据源代理工厂:方法二,使用list集合,按文件名搜索匹配的映射文件 --><!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"p:dataSource-ref="dataSource"><property name="mappingLocations"><list><value>classpath*:/com/**/*.hbm.xml</value></list></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.format_sql">${hibernate.format_sql}</prop><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop><prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop><prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop><prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop></props></property></bean> --><!-- 配置Hibernate的数据源代理工厂:方法三,使用p属性通配符,按目录搜索映射文件 --><!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"p:dataSource-ref="dataSource" p:mappingDirectoryLocations="classpath*:/com/**/domain"><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.format_sql">${hibernate.format_sql}</prop><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop><prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop><prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop><prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop></props></property></bean> --><!-- 配置Hibernate的数据源代理工厂:方法四,使用hibernate.cfg.xml --><!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"p:dataSource-ref="dataSource" p:configLocation="classpath:hibernate.cfg.xml"></bean> -->  <!-- 配置事务管理器 --><bean id="transactionManager"class="org.springframework.orm.hibernate4.HibernateTransactionManager"p:sessionFactory-ref="sessionFactory" /><!-- 配置声明式事务:方法一,在Service实现类或者public实现方法上使用注解@Transactional,则此类或方法就会启用事务机制 --><tx:annotation-driven transaction-manager="transactionManager" /><!-- 配置声明式事务:方法二,使用tx/aop命名空间的配置(其实还有方法三,由于快要过时不推荐使用了,这里就不给出方法三的配置了) --><!-- <tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="insert*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="edit*" propagation="REQUIRED" /><tx:method name="save*" propagation="REQUIRED" /><tx:method name="add*" propagation="REQUIRED" /><tx:method name="new*" propagation="REQUIRED" /><tx:method name="set*" propagation="REQUIRED" /><tx:method name="remove*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="change*" propagation="REQUIRED" /><tx:method name="get*" propagation="REQUIRED" read-only="true" /><tx:method name="find*" propagation="REQUIRED" read-only="true" /><tx:method name="load*" propagation="REQUIRED" read-only="true" /><tx:method name="search*" propagation="REQUIRED" read-only="true" /><tx:method name="*" propagation="REQUIRED" read-only="true" /></tx:attributes></tx:advice><aop:config><aop:pointcut id="mypointcut" expression="execution(* com.**.service..*.*(..))" /><aop:advisor advice-ref="txAdvice" pointcut-ref="mypointcut" /></aop:config> -->  <!-- 下面三个Bean的配置可有可无,但配置后用处更大,通常用于BaseDao类、其他Dao类或特殊工具类中 --><bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate"p:sessionFactory-ref="sessionFactory" /><bean id="hibernateDaoSupport" class="org.springframework.orm.hibernate4.support.HibernateDaoSupport"p:hibernateTemplate-ref="hibernateTemplate" abstract="true"/><bean id="sessionFactoryUtils" class="org.springframework.orm.hibernate4.SessionFactoryUtils" abstract="true"/></beans>

applicationContextQuartz定时任务XML配置

<?xml version="1.0" encoding="UTF-8" ?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">        <!-- 定时任务Bean --><bean id="firstQuartz" class="com.xmm.demo.quartz.FirstQuartz" /><!-- 定义调用对象和调用对象的方法 --><bean id="testDetail"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"><!-- 调用的类 --><property name="targetObject" ref="firstQuartz" /><!-- 调用类中的方法 --><property name="targetMethod" value="doTestJob" /><!-- 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 --><property name="concurrent" value="false" /></bean><!-- 定义触发时间 --><!-- quartz-1.8以前的配置 --><!-- <bean id="myJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"><ref bean="testDetail" /></property><property name="cronExpression"><value>0/10 * * * * ?</value></property></bean> --><!--           每隔5秒执行一次:*/5 * * * * ? --><!--                  每隔1分钟执行一次:0 */1 * * * ? --><!--                  每天23点执行一次:0 0 23 * * ? --><!--                  每天凌晨1点执行一次:0 0 1 * * ? --><!--                  每月1号凌晨1点执行一次:0 0 1 1 * ? --><!--                  每月最后一天23点执行一次:0 0 23 L * ? --><!--                  每周星期天凌晨1点实行一次:0 0 1 ? * L --><!--                  在26分、29分、33分执行一次:0 26,29,33 * * * ? --><!--                  每天的0点、13点、18点、21点都执行一次:0 0 0,13,18,21 * * ?  --><!-- quartz-2.x后的配置 --><bean id="myJobTrigger"class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"><property name="jobDetail"><ref bean="testDetail" /></property><property name="cronExpression"><value>0 */10 * * * ?</value></property></bean><!-- 总管理类:如果lazy-init='false',那么容器启动后就会执行调度程序 --><!-- 如果lazy-init='true',则需要实例化该bean才能执行调度程序 --><bean name="testQuertz" lazy-init="false" autowire="no"class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="triggers"><list><ref bean="myJobTrigger" /></list></property><!-- <property name="autoStartup" value="true"/> --></bean></beans>


全注解applicationContext-common配置

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"><!-- 启用spring注解支持 --><context:annotation-config /><!--配数据源 --><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /><property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl" /><property name="username" value="ssh" /><property name="password" value="ssh" /></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop><prop key="hibernate.show_sql">true</prop><prop key="hibernate.hbm2ddl.auto">update</prop><prop key="default_schema">ssh</prop></props></property>    <!-- 如果使用配置文件 --><!-- <property name="mappingLocations"> <list> <value>classpath:com/jialin/entity/User.hbm.xml</value> </list> </property> --><property name="annotatedClasses"><list><value>com.jialin.entity.User</value></list></property></bean><!-- 配置事务管理器 --><bean id="transactionManager"class="org.springframework.orm.hibernate4.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory" /></bean><!-- 事务的传播特性 --><tx:advice id="txadvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="modify*" propagation="REQUIRED" /> <!--hibernate4必须配置为开启事务 否则 getCurrentSession()获取不到--><tx:method name="*" propagation="REQUIRED" read-only="true" /></tx:attributes></tx:advice><!-- 那些类那些方法使用事务 --><aop:config>  <!-- 只对业务逻辑层实施事务 --><aop:pointcut id="allManagerMethod"expression="execution(* com.jialin.service.*.*(..))" /><aop:advisor pointcut-ref="allManagerMethod" advice-ref="txadvice" /></aop:config></beans>

全注解applicationContextBean配置

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"><!-- Spring管理Struts2的Action --><bean name="loginAction" class="com.jialin.action.LoginAction" scope="prototype"></bean><bean name="userMainAction" class="com.opensymphony.xwork2.ActionSupport" scope="prototype"></bean><bean name="userAction" class="com.jialin.action.UserAction" scope="prototype"><!-- <property name="userManage" ref="userManage"></property> --></bean><!-- Spring管理Struts2的Interceptor --><bean name="checkLoginInterceptor" class="com.jialin.interceptor.CheckLogin" scope="prototype"></bean><bean name="userManage" class="com.jialin.service.UserManageImp"><!-- <property name="userDao" ref="userDao"></property> --></bean><bean name="userDao" class="com.jialin.dao.UserDaoImp"><property name="sessionFactory" ref="sessionFactory" /></bean></beans>



Struts2.xml的配置

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts><package name="default" namespace="/" extends="json-default"><!-- 基础数据 --><action name="basicAction" class="BasicActionDao"><result type="json"><param name="root">dataMap</param></result><result name="addB" type="json"><param name="root">dataMap</param></result><result name="delB" type="json"><param name="root">dataMap</param></result><result name="upB" type="json"><param name="root">dataMap</param></result></action><!-- 用户管理 --><action name="userAction" class="userActionDao"><result type="json"><param name="root">user</param></result><result name="findBy" type="json"><param name="root">sysuser</param></result><result name="updateuse" type="json"><param name="root">jsonMap</param></result><result name="addUs" type="json"><param name="root">jsonMap</param></result><result name="deleu" type="json"><param name="root">jsonMap</param></result></action><action name="assignTAction" class="userActionDao">    <result type="json">        <param name="root">nodes</param>    </result></action><action name="righAction" class="userActionDao">    <result type="json">      <param name="root">nodes</param></result></action><action name="roleAction" class="roleActionDao"><result type="json"><param name="root">dataMap</param><param name="excludeProperties"> rows\[\d+\]\.sysRights </param></result></action><action name="updateAction" class="roleActionDao">    <result type="json">      <param name="root">jsonMap</param></result> <result name="addrol" type="json">      <param name="root">jsonMap</param></result> <result name="delero" type="json">      <param name="root">jsonMap</param></result><result name="roleFind" type="json">      <param name="root">role</param></result><result name="upRole" type="json">      <param name="root">jsonMap</param></result><result name="upChan" type="json">      <param name="root">salech</param></result><result name="fRole" type="json">      <param name="root">rol</param>      </result></action><action name="usersAction" class="userActionDao">    <result type="json">      <param name="root">dataMap</param>       <param name="excludeProperties">             rows\[\d+\]\.sysRole\.sysRights         </param></result></action></package></struts>    

web.xml的配置

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">  <display-name></display-name>  <context-param>    <param-name>contextConfigLocation</param-name>    <param-value>classpath:applicationContext.xml</param-value>  </context-param>  <listener>    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <filter>    <filter-name>openSessionInView</filter-name>    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>  </filter>  <filter-mapping>    <filter-name>openSessionInView</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping>  <welcome-file-list>    <welcome-file>login.jsp</welcome-file>  </welcome-file-list>  <filter>    <filter-name>struts2</filter-name>    <filter-class>  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter  </filter-class>  </filter>  <filter-mapping>    <filter-name>struts2</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping></web-app>

web.xml配置

<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><!-- 配置初始打开的页面 --><!-- <welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file></welcome-file-list> --><!-- Spring 容器加载 --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:SpringConf.xml</param-value></context-param><!-- SpringMVC的前端控制器 --><servlet><servlet-name>MyDispatcher</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!-- 加载配置文件路径 --><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:SpringMVC-servlet.xml</param-value></init-param><!-- 何时启动 大于0的值表示容器启动时初始化此servlet,正值越小优先级越高 --><load-on-startup>1</load-on-startup></servlet><!-- Spring MVC配置文件结束 --><!-- SpringMVC拦截设置 --><servlet-mapping><servlet-name>MyDispatcher</servlet-name><!-- 由SpringMVC拦截所有请求 --><url-pattern>/</url-pattern></servlet-mapping><!-- SpringMVC拦截设置结束 --><!--解决中文乱码问题 --><filter><filter-name>CharacterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param></filter><filter-mapping><filter-name>CharacterEncodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>




0 0
原创粉丝点击