Spring mvc 异常拦截 配置

<value>/WEB-INF/languages/core_admin/messages</value>
<bean id= "messageSource" class = "org.springframework.context.support.ReloadableResourceBundleMessageSource" >
     <property name= "cacheSeconds" value= "-1" />
     <property name= "basenames" >
         <list>
             <value>/WEB-INF/languages/core_admin/messages</value>
         </list>
     </property>
</bean>
 
<!--文件上传-->
<bean id= "multipartResolver" class = "org.springframework.web.multipart.commons.CommonsMultipartResolver" />
 
<!--通过注解,把一个URL映射到Controller类的方法上-->
<bean  class = "org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
     <property name= "webBindingInitializer" ><!--重写WebBindingInitializer-->
         <bean  class = " com.cms.common.web.springmvc.BindingInitializer" />
     </property>
</bean>
 
<!--用于Spring 从外部属性文件中载入属性,并使用这些属性值替换Spring 配置文件中的占位符变量(${varible})。 -->
<bean id= "propertyConfigurer" class = "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
     <property name= "locations" >
         <list>
             <value>/WEB-INF/config/firewall.properties</value>
         </list>
     </property>
</bean>
 
<!--    DefaultAnnotationHandlerMapping-映射url到被RequestMapping注解的controller或者下面的方法-->
<bean  class = "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" >
     <property name= "interceptors" >
         <list>
             <ref bean= "adminContextInterceptor" />
             <ref bean= "adminLocaleIntercept" />
             <ref bean= "fireWallInterceptor" />
         </list>
     </property>
</bean>
<!--拦截器-->
<bean id= "adminContextInterceptor" class = "com.cms.cms.web.AdminContextInterceptor" >
     <property name= "auth" value= "true" />
     <property name= "loginUrl" value= "/admin/cms/login.do" />
     <property name= "returnUrl" value= "/admin/cms/index.do" />
     <property name= "excludeUrls" >
         <list>
             <value>/login. do </value>
             <value>/logout. do </value>
         </list>
     </property>
</bean>
<bean id= "adminLocaleIntercept" class = "com.cms.cms.web.AdminLocaleInterceptor" />
<bean id= "fireWallInterceptor" class = "com.cms.cms.web.FireWallInterceptor" ></bean>
 
<!--Cookie相关-->
<bean id= "localeResolver" class = "org.springframework.web.servlet.i18n.CookieLocaleResolver" >
     <property name= "cookieName" value= "clientlanguage" />
     <property name= "cookieMaxAge" value= "-1" />
</bean>
 
<!--定义一场处理-->
<bean  class = "org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" >
     <property name= "exceptionMappings" >
         <props>
             <prop key= "org.springframework.web.bind.MissingServletRequestParameterException" >/error/requiredParameter</prop>
             <prop key= "org.springframework.beans.TypeMismatchException" >/error/mismatchParameter</prop>
             <prop key= "org.springframework.web.bind.ServletRequestBindingException" >/error/bindException</prop>
             <prop key= "org.springframework.dao.DataIntegrityViolationException" >/error/integrityViolation</prop>
         </props>
     </property>
</bean>
<!--freemarker配置-->
<bean id= "freemarkerViewResolver" class = "com.cms.common.web.springmvc.RichFreeMarkerViewResolver" >
     <property name= "prefix" value= "/cms_sys/" />
     <property name= "suffix" value= ".html" />
     <property name= "contentType" value= "text/html; charset=UTF-8" />
     <property name= "exposeRequestAttributes" value= "false" />
     <property name= "exposeSessionAttributes" value= "false" />
     <property name= "exposeSpringMacroHelpers" value= "true" />
</bean>
<bean id= "freemarkerConfig" class = "org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer" >
     <property name= "templateLoaderPath" value= "/WEB-INF" />
     <property name= "freemarkerVariables" >
         <map>
             <!--在FCK编辑器中需要用到appBase,以确定connector路径。-->
             <entry key= "appBase" value= "/admin/cms" />
             <!--后台管理权限控制-->
             <entry key= "cms_perm" value-ref= "cms_perm" />
             <entry key= "text_cut" value-ref= "text_cut" />
             <entry key= "html_cut" value-ref= "html_cut" />
         </map>
     </property>
     <property name= "freemarkerSettings" >
         <props>
             <prop key= "template_update_delay" > 0 </prop>
             <prop key= "defaultEncoding" >UTF- 8 </prop>
             <prop key= "url_escaping_charset" >UTF- 8 </prop>
             <prop key= "locale" >zh_CN</prop>
             <prop key= "boolean_format" > true , false </prop>
             <prop key= "datetime_format" >yyyy-MM-dd HH:mm:ss</prop>
             <prop key= "date_format" >yyyy-MM-dd</prop>
             <prop key= "time_format" >HH:mm:ss</prop>
             <prop key= "number_format" > 0 .######</prop>
             <prop key= "whitespace_stripping" > true </prop>
             <prop key= "auto_import" >/ftl/cms/index.ftl as p,/ftl/spring.ftl as s</prop>
         </props>
     </property>
</bean>
 
<!--见 89 行-->
<context:annotation-config/>
 
<!--action注入配置文件-->
< import resource= "admin-action.xml" />

你可能感兴趣的:(spring mvc)