<aop:aspectj-autoproxy /> 这一段一定要写在SpringMVC的配置文件中,否则不会起作用
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:task="http://www.springframework.org/schema/task" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd">
<!-- 自动扫描service -->
<!-- 注解驱动 -->
<mvc:annotation-driven />
<context:component-scan base-package="com.*"/>
<context:annotation-config />
<!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"><value>/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean>
<bean id="httpRequestHandlerAdapter" class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter" />
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.FormHttpMessageConverter" />
<bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter" />
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/x-www-form-urlencoded;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
<value>text/plain;charset=UTF-8</value>
<value>*/*;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8" />
<property name="maxUploadSize" value="32505856" /><!-- 上传文件大小限制为31M,31*1024*1024 -->
<property name="maxInMemorySize" value="4096" />
</bean>
<!-- SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException -->
<!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 -->
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<!-- 遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/jsp/error_fileupload.jsp页面 -->
<prop key="org.springframework.web.multipart.MaxUploadSizeExceededException"> </prop>
</props>
</property>
</bean>
<aop:aspectj-autoproxy />
<bean id="logInterceptor" class="com.*.framework.interceptor.LogInterceptor"></bean>
<!-- 拦截器配置 -->
<!--<mvc:interceptors>
配置Token拦截器,防止用户重复提交数据 --><!--
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="cn.sh.tuban.framework.interceptor.token.TokenInterceptor" />
</mvc:interceptor>
</mvc:interceptors>-->
</beans>
相关推荐
NULL 博文链接:https://panyongzheng.iteye.com/blog/2084629
SpringMVC中的拦截器-拦截器方法的作用和执行顺序.avi
企业级开发-SpringMVC使用拦截器实现用户登录权限验证实验报告
本篇文章主要介绍了防止SpringMVC拦截器拦截js等静态资源文件的解决方法,具有一定的参考价值,有兴趣的同学可以了解一下
springmvc 拦截器
SpringMVC拦截器例子详解,
极客学院java中级课程,SpringMVC系列教材——SpringMVC 中的拦截器与异常处理
SpringMvc 拦截器 原理清楚,代码简单,值得学习!
SpringMVC学习(十二)——SpringMVC中的拦截器
自定义拦截器的具体实现、自定义拦截器的配置方式、多个拦截器之间的执行执行顺序
SpringMVC拦截器的使用,通俗易懂!
SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理,这篇文章主要介绍了详解SpringMVC中使用Interceptor拦截器,有兴趣的可以了解一下。
SpringMVC框架下对限定时间拦截(适用于初学者)
springmvc-机制(拦截器、aop、异常).pdfspringmvc-机制(拦截器、aop、异常).pdf
SpringMVC拦截器源代码
可下载部署直接运行
文档内有springmvc拦截器的配置
springmvc拦截器实现登录验证
Springmvc框架进行登录验证,除了某些特定的action请求不需要登录验证,例如登录,注册等。其他的action请求均需要登录验证,若没有登录则直接调到登录界面。若登录成功,则通过拦截
springMVC 拦截器源代码 内有详细文档介绍操作 @Override public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception { //可以通过...