springMVC的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:aop = "http://www.springframework.org/schema/aop"
  xmlns:context = "http://www.springframework.org/schema/context"
  xmlns:mvc = "http://www.springframework.org/schema/mvc"  xmlns:jee = "http://www.springframework.org/schema/jee"
  xmlns:lang = "http://www.springframework.org/schema/lang"  xmlns:p = "http://www.springframework.org/schema/p"
  xmlns:tx = "http://www.springframework.org/schema/tx"  xmlns:util = "http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
   http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
   http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
   http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
   http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
  <!-- <context:component-scan base-package="package_name"/> -->
  < context:component-scan  base-package = "org.lee"  />
  < mvc:annotation-driven  />
  <!-- 注解实现日记记录 -->
  < aop:aspectj-autoproxy  />
 
  < bean
   class = "org.springframework.web.servlet.view.InternalResourceViewResolver" >
   < property  name = "prefix"  value = "/WEB-INF/view/"  />    <!-- path before request -->
   < property  name = "suffix"  value = ".jsp"  />   <!-- suffix -->
  </ bean >
 
  <!-- 国际化 -->
  < bean  id = "messageSource"
   class = "org.springframework.context.support.ResourceBundleMessageSource" >
   < property  name = "basenames"  value = "i18n.message" ></ property >
   < property  name = "defaultEncoding"  value = "UTF-8"  />
  </ bean >
  <!-- 基于Session的国际化配置 -->
  < bean  id = "localeResolver"
   class = "org.springframework.web.servlet.i18n.SessionLocaleResolver" ></ bean >
  <!-- 动态语言切换 -->
  < bean  id = "localeChangeInterceptor"
   class = "org.springframework.web.servlet.i18n.LocaleChangeInterceptor" >
   < property  name = "paramName"  value = "locale"  />
  </ bean >
 
  <!-- 静态资源访问 -->
  < mvc:resources  location = "/My97DatePicker/"  mapping = "/My97DatePicker/**"  />
  < mvc:resources  location = "/static/lib/"  mapping = "/static/lib/**"  />
  < mvc:resources  location = "/static/css/"  mapping = "/static/css/**"  />
  < mvc:resources  location = "/static/assets/"  mapping = "/static/assets/**"  />
  < mvc:resources  location = "/static/js/"  mapping = "/static/js/**"  />
  < mvc:resources  location = "/static/js/jqprint/"  mapping = "/static/js/jqprint/**"  />
  < mvc:resources  location = "/static/bootstrap-3.3.5-dist/css/"
   mapping = "/static/bootstrap-3.3.5-dist/css/**"  />
  < mvc:resources  location = "/static/bootstrap-3.3.5-dist/js/"
   mapping = "/static/bootstrap-3.3.5-dist/js/**"  />
  < mvc:resources  location = "/static/bootstrap-3.3.5-dist/fonts/"
   mapping = "/static/bootstrap-3.3.5-dist/fonts/**"  />
  <!-- Bootstrap-Multiselect -->
  < mvc:resources  location = "/static/bootstrap-multiselect-0.9.13/dist/css/"
   mapping = "/static/bootstrap-multiselect-0.9.13/dist/css/**"  />
  < mvc:resources  location = "/static/bootstrap-multiselect-0.9.13/dist/js/"
   mapping = "/static/bootstrap-multiselect-0.9.13/dist/js/**"  />
  < mvc:resources  location = "/static/bootstrap-multiselect-0.9.13/dist/less/"
   mapping = "/static/bootstrap-multiselect-0.9.13/dist/less/**"  />
  < mvc:resources  location = "/static/bootstrap-multiselect-0.9.13/docs/css/"
   mapping = "/static/bootstrap-multiselect-0.9.13/docs/css/**"  />
  < mvc:resources  location = "/static/bootstrap-multiselect-0.9.13/docs/js/"
   mapping = "/static/bootstrap-multiselect-0.9.13/docs/js/**"  />
  < mvc:resources  location = "/static/bootstrap-multiselect-0.9.13/docs/less/"
   mapping = "/static/bootstrap-multiselect-0.9.13/docs/less/**"  />
 
  <!-- JSR 303 Validator -->
  < bean  id = "validator"
   class = "org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" >
   < property  name = "providerClass"  value = "org.hibernate.validator.HibernateValidator"  />
   < property  name = "validationMessageSource"  ref = "messageSource"  />
  </ bean >
  < mvc:annotation-driven  validator = "validator"  />
  <!-- 数据库配置 -->
  < bean  id = "dataSource"  class = "com.alibaba.druid.pool.DruidDataSource"
   init-method = "init"  destroy-method = "close" >
   <!-- MySQL数据库配置 -->
   < property  name = "url"
    value = "jdbc:mysql://localhost:3306/apj?useUnicode=true&amp;characterEncoding=utf-8"  />
   < property  name = "username"  value = "root"  />
   < property  name = "password"  value = "123456"  />
  </ bean >
 
  <!-- 配置jdbcTemplate -->
  < bean  id = "jdbcTemplate"  class = "org.springframework.jdbc.core.JdbcTemplate"
   abstract = "false"  lazy-init = "false"  autowire = "default" >
   < property  name = "dataSource" >
    < ref  bean = "dataSource"  />
   </ property >
  </ bean >
 
  <!--配置Hibernate -->
  < bean  id = "sessionFactory"
   class = "org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
   < property  name = "dataSource"  ref = "dataSource"  />
   < property  name = "packagesToScan"  value = "org.lee.model" ></ property >
   < property  name = "hibernateProperties" >
    < props >
     <!-- 方言 -->
     < prop  key = "dialect" >org.hibernate.dialect.MySQL5Dialect</ prop >
     <!-- 控制台显示SQL -->
     < prop  key = "show_sql" >true</ prop >
     <!-- 自动更新表结构 -->
     < prop  key = "hbm2ddl.auto" >update</ prop >
    </ props >
   </ property >
  </ bean >
  
  
  <!--配置Hibernate事务 -->
  < bean  id = "transactionManager"
   class = "org.springframework.orm.hibernate4.HibernateTransactionManager" >
   < property  name = "sessionFactory"  ref = "sessionFactory"  />
  </ bean >
  < tx:annotation-driven  transaction-manager = "transactionManager"  />
  <!-- 考题管理的ajax相关配置 -->
  < bean
   class = "org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
   < property  name = "messageConverters" >
    < list >
     < ref  bean = "mappingJackson2HttpMessageConverter"  />
    </ list >
   </ property >
  </ bean >
  < bean  id = "mappingJackson2HttpMessageConverter"
   class = "org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" >
   < property  name = "supportedMediaTypes" >
    < list >
     < value >application/json;charset=UTF-8</ value >
     < value >text/html;charset=UTF-8</ value >
     < value >text/json;charset=UTF-8</ value >
    </ list >
   </ property >
  </ bean >
  <!-- 上传 -->
  < bean  id = "multipartResolver"
   class = "org.springframework.web.multipart.commons.CommonsMultipartResolver"  />
 
  <!-- 登录权限 -->
  < mvc:interceptors >
   < mvc:interceptor >
    < mvc:mapping  path = "/**"  />
    < mvc:exclude-mapping  path = "/login"  />
    < mvc:exclude-mapping  path = "/logout"  />
    < mvc:exclude-mapping  path = "/static"  />
    < bean  class = "org.lee.Interceptor.LoginInterceptor" ></ bean >
   </ mvc:interceptor >
  </ mvc:interceptors >
 
</ beans >
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值