Spring MVC配置(备忘)
来源:互联网 发布:爰淘宝商城 编辑:程序博客网 时间:2024/05/22 08:01
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd" > <!-- 默认的注解映射的支持:它会自动注册HandlerMapping、HandlerAdapter、ExceptionResolver的相关实例 --> <mvc:annotation-driven /> <!-- 自动扫描的包名 --> <!-- 扫描类包,将标注Spring注解的类自动转化Bean,同时完成Bean的注入 --><context:component-scan base-package="com.chinagpay.abroad" /> <!-- 视图解释类 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/pages/"/> <property name="suffix" value=".jsp"/><!--可为空,方便实现自已的依据扩展名来选择视图解释类的逻辑 --> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> </bean> <!-- 国际化 --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="com.chinagpay.abroad.i18n.messages"/> <property name="defaultEncoding" value="utf-8"></property> </bean> <!-- 通过cookie获取本地语言,可通过XXX?locale=en_US或者zh_CH.自动切换语言。 --> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" /> <!-- 拦截器 --> <mvc:interceptors> <!-- 过滤用户是否登录 --> <mvc:interceptor> <mvc:mapping path="/user/**"/> <mvc:mapping path="/edu/**"/> <mvc:mapping path="/cross/**"/> <bean class="com.chinagpay.abroad.common.interceptors.LoginInterceptor" /> </mvc:interceptor> <!-- 防止表单重发提交 --><mvc:interceptor> <mvc:mapping path="/user/**"/> <bean class="com.chinagpay.abroad.common.interceptors.TokenInterceptor" /> </mvc:interceptor> <!-- 过滤特殊字符 --><mvc:interceptor> <mvc:mapping path="/**/**"/> <bean class="com.chinagpay.abroad.common.interceptors.ContentFilter" /> </mvc:interceptor> <!-- 国际化 --> <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" /></mvc:interceptors> <!-- 对静态资源文件的访问 方案一 (二选一) --> <!--<mvc:default-servlet-handler/> --> <mvc:resources mapping="/images/**" location="/images/" cache-period="31556926"/><mvc:resources mapping="/js/**" location="/js/" cache-period="31556926"/><mvc:resources mapping="/css/**" location="/css/" cache-period="31556926"/><mvc:resources mapping="/doc/**" location="/doc/" cache-period="31556926"/><!-- 支持上传 --><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" ><property name="defaultEncoding" value="utf-8" /></bean> <!-- 加载jdbc配置文件 --><context:property-placeholder location="/WEB-INF/jdbc.properties" /><!-- 数据源 ,DBCP连接池--><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 name="password" value="${jdbc.password}"/><property name="initialSize" value="2"/><property name="maxActive" value="10"/><property name="maxIdle" value="10"/><property name="maxWait" value="1000"/><property name="poolPreparedStatements" value="true"/></bean><!-- 配置Jdbc模板 --><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property></bean><!-- 配置事务管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean><!-- 用注解来实现事务管理 --><tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/><!-- dao注入 --><!-- <bean id="userService" class="com.chinagpay.abroad.service.impl.UserServiceImpl"> <property name="jdbcTemplate" ref="jdbcTemplate"></property></bean>--></beans>
0 0
- Spring MVC配置(备忘)
- spring配置备忘
- spring-MVC配置(一)
- spring-MVC配置(二)
- 【spring mvc】spring-mvc配置
- spring mvc 配置(xml配置详解)
- spring mvc 配置(xml配置详解)
- spring mvc 配置(xml配置详解)
- spring mvc 配置(xml配置详解)
- spring mvc 配置(xml配置详解)
- spring mvc 配置(xml配置详解)
- Spring Web MVC框架(八) 配置Spring Web MVC
- Sqlite jdbc spring配置(备忘)
- Spring Cache + Redis配置备忘
- Spring MVC国际化配置(转载)
- spring MVC 配置入门总结(1)
- spring MVC框架配置(详细版)
- Spring MVC事务配置(简)
- web 记住密码
- Linux命令查看X86平台 ARM平台上可执行文件与库的依赖关系
- Writing Sentences [1]
- 人生就是一条绳子
- CGContextAddArcToPoint和CGContextAddArc
- Spring MVC配置(备忘)
- HDU1020 - Encoding (模拟)
- php对特殊字符的处理操作的总结
- EventBus、Handler、Broadcast用法
- 问题--pip安装软件出现下面的报错
- 浅谈Android的资源编译过程
- C# 操作注册安装、开启、停止、卸载服务
- flex如何监听自动产生的滚动条呢,是个问题
- c++ const用法总结