关于springmvc的配置文件

开发常用的springmvc.xml配置文件,spring 3.0 spring-servlet.xml配置。

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Bean头部 -->
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:p="http://www.springframework.org/schema/p"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc"
  7. xmlns:context="http://www.springframework.org/schema/context"
  8. xmlns:util="http://www.springframework.org/schema/util"
  9. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  10. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
  11. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  12. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
  13. <!-- 加载权限设置 -->
  14. <bean id="security" class="com.boaotech.util.Security"
  15. p:contextConfigLocation="WEB-INF/security.xml" />
  16. <!-- 加载菜单项 -->
  17. <bean id="menus" class="com.boaotech.util.Menus"
  18. p:contextConfigLocation="WEB-INF/menus.xml" p:security-ref="security" />
  19. <!-- Json返回格式化转换 -->
  20. <bean id="mappingJacksonHttpMessageConverter"
  21. class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
  22. <!-- 设置全局日期参数的字符串表示格式 -->
  23. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
  24. <property name="webBindingInitializer">
  25. <bean class="com.boaotech.util.CommonBindingInitializer"/>
  26. </property>
  27. <property name="messageConverters">
  28. <list>
  29. <ref bean="mappingJacksonHttpMessageConverter"/>
  30. </list>
  31. </property>
  32. </bean>
  33. <!-- 激活@Controller模式 -->
  34. <mvc:annotation-driven />
  35. <!-- 对包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能  需要更改-->
  36. <context:component-scan base-package="com.boaotech.zhaotaoerp" />
  37. <context:annotation-config/>
  38. <!-- 激活计划任务注解 -->
  39. <task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
  40. <task:scheduler id="myScheduler" pool-size="1"/>
  41. <task:executor id="myExecutor" pool-size="1"/>
  42. <!-- 配置拦截器 -->
  43. <mvc:interceptors>
  44. <bean id="authorizeInterceptor" class="com.boaotech.util.AuthorizeInterceptor" />
  45. </mvc:interceptors>
  46. <!-- 类名到视图名的自动映射 -->
  47. <!-- bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/ -->
  48. <!-- FreeMarker配置文件 -->
  49. <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
  50. <property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
  51. <property name="freemarkerSettings">
  52. <props>
  53. <prop key="template_update_delay">5</prop>
  54. <prop key="default_encoding">UTF-8</prop>
  55. <prop key="locale">zh_CN</prop>
  56. </props>
  57. </property>
  58. </bean>
  59. <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
  60. <bean id="viewResolver"
  61. class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
  62. p:cache="true" p:prefix="" p:suffix=".ftl"
  63. p:contentType="text/html;charset=UTF-8"
  64. p:exposeRequestAttributes="true" p:exposeSessionAttributes="true"
  65. />
  66. <!-- bean id="viewResolver"
  67. class="org.springframework.web.servlet.view.InternalResourceViewResolver"
  68. p:viewClass="org.springframework.web.servlet.view.JstlView" p:prefix="/WEB-INF/jsp/"
  69. p:suffix=".jsp" / -->
  70. </beans>
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Bean头部 -->
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:p="http://www.springframework.org/schema/p"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc"
  7. xmlns:context="http://www.springframework.org/schema/context"
  8. xmlns:util="http://www.springframework.org/schema/util"
  9. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  10. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
  11. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  12. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
  13. <!-- 加载权限设置 -->
  14. <bean id="security" class="com.boaotech.util.Security"
  15. p:contextConfigLocation="WEB-INF/security.xml" />
  16. <!-- 加载菜单项 -->
  17. <bean id="menus" class="com.boaotech.util.Menus"
  18. p:contextConfigLocation="WEB-INF/menus.xml" p:security-ref="security" />
  19. <!-- Json返回格式化转换 -->
  20. <bean id="mappingJacksonHttpMessageConverter"
  21. class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
  22. <!-- 设置全局日期参数的字符串表示格式 -->
  23. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
  24. <property name="webBindingInitializer">
  25. <bean class="com.boaotech.util.CommonBindingInitializer"/>
  26. </property>
  27. <property name="messageConverters">
  28. <list>
  29. <ref bean="mappingJacksonHttpMessageConverter"/>
  30. </list>
  31. </property>
  32. </bean>
  33. <!-- 激活@Controller模式 -->
  34. <mvc:annotation-driven />
  35. <!-- 对包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能  需要更改-->
  36. <context:component-scan base-package="com.boaotech.zhaotaoerp" />
  37. <context:annotation-config/>
  38. <!-- 激活计划任务注解 -->
  39. <task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
  40. <task:scheduler id="myScheduler" pool-size="1"/>
  41. <task:executor id="myExecutor" pool-size="1"/>
  42. <!-- 配置拦截器 -->
  43. <mvc:interceptors>
  44. <bean id="authorizeInterceptor" class="com.boaotech.util.AuthorizeInterceptor" />
  45. </mvc:interceptors>
  46. <!-- 类名到视图名的自动映射 -->
  47. <!-- bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/ -->
  48. <!-- FreeMarker配置文件 -->
  49. <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
  50. <property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
  51. <property name="freemarkerSettings">
  52. <props>
  53. <prop key="template_update_delay">5</prop>
  54. <prop key="default_encoding">UTF-8</prop>
  55. <prop key="locale">zh_CN</prop>
  56. </props>
  57. </property>
  58. </bean>
  59. <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
  60. <bean id="viewResolver"
  61. class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
  62. p:cache="true" p:prefix="" p:suffix=".ftl"
  63. p:contentType="text/html;charset=UTF-8"
  64. p:exposeRequestAttributes="true" p:exposeSessionAttributes="true"
  65. />
  66. <!-- bean id="viewResolver"
  67. class="org.springframework.web.servlet.view.InternalResourceViewResolver"
  68. p:viewClass="org.springframework.web.servlet.view.JstlView" p:prefix="/WEB-INF/jsp/"
  69. p:suffix=".jsp" / -->
  70. </beans>
上一篇:HDU 1423 Greatest Common Increasing Subsequence ——动态规划


下一篇:[原]poj-1611-The Suspects(水并查集)