| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
- 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.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
- <!-- 自动扫描指定包下的 @Controller 注解 -->
- <!-- 自动扫描指定包下的 @Controller 注解 -->
- <context:component-scan base-package="com.ssm">
- <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
- </context:component-scan>
-
- <!-- <bean id="InitListener" class="com.ssm.common.InitListener" /> -->
-
- <mvc:interceptors>
- <!-- <mvc:interceptor>
- <mvc:mapping path="/**" />
- <mvc:exclude-mapping path="/resources/**" />
- <mvc:exclude-mapping path="/login" />
- <bean class="com.ssm.interceptor.LoginInterceptor" />
- </mvc:interceptor> -->
- <mvc:interceptor>
- <mvc:mapping path="/**" />
- <mvc:exclude-mapping path="/login" />
- <mvc:exclude-mapping path="/saveUser" />
- <mvc:exclude-mapping path="/deleteUser" />
- <mvc:exclude-mapping path="/resources/**" />
- <bean class="com.ssm.interceptor.MenuInterceptor" />
- </mvc:interceptor>
- </mvc:interceptors>
- <!-- 设置静态资源的访问映射 location 为静态资源所在项目中的存放路径, mapping 为使用者引用静态的路径 -->
- <mvc:resources location="/resources/" mapping="/resources/**" />
- <!-- <mvc:resources location="/upload/" mapping="/upload/**" /> -->
-
- <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
- <property name="messageConverters">
- <list>
- <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
- <bean class="org.springframework.http.converter.StringHttpMessageConverter">
- <property name="writeAcceptCharset" value="false" /><!-- See SPR-7316 -->
- <!-- @ResponseBody 返回类型为String的中文编码问题 -->
- <property name = "supportedMediaTypes">
- <list>
- <value>text/html;charset=UTF-8</value>
- </list>
- </property>
- </bean>
- <bean class="org.springframework.http.converter.ResourceHttpMessageConverter" />
- <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" />
- <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
- <bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />
- <bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" />
- <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter" />
- <bean class="org.springframework.http.converter.FormHttpMessageConverter" />
- </list>
- </property>
- </bean>
-
- <bean id="initConfig" class="com.ssm.common.SpringInitConfig"/>
- <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
- <!-- <property name="maxUploadSize"><value>100000</value></property> -->
- <property name="defaultEncoding"><value>UTF-8</value></property>
- </bean>
- <!-- Spring AOP for authority -->
- <bean id="authorityAdvice" class="com.ssm.web.AuthorityAdvice"></bean>
- <bean id="pageNavigation" class="com.ssm.web.PageNavigation"></bean>
- <aop:config>
- <aop:pointcut id="lap"
- expression="execution(* com.ssm.controller.*.*(..)) or execution(* com.ssm.controller.*.*.*(..))" />
- <aop:aspect ref="authorityAdvice">
- <aop:around pointcut-ref="lap" method="aroundMethod" />
- </aop:aspect>
-
- <aop:aspect ref="pageNavigation">
- <aop:around pointcut-ref="lap" method="aroundMethod2" />
- </aop:aspect>
- </aop:config>
-
- <!-- 根据不同的请求返回不同的view -->
- <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
- <!-- 设置为true以忽略对Accept Header的支持 -->
- <property name="ignoreAcceptHeader" value="true" />
- <!-- 请求名称带格式扩展名至mimeType的映射,即 /user.json => application/json -->
- <property name="mediaTypes">
- <map>
- <entry key="json" value="application/json" />
- </map>
- </property>
- <!-- 请求名称中沒有格式扩展名或沒用格式扩展名的mediaTypes時即: "/user/1" 時的默认展示的形式 -->
- <property name="defaultContentType" value="text/html" />
- <!-- /userinfo/123?format=json 的支持 -->
- <property name="favorParameter" value="false" />
- <property name="viewResolvers">
- <list>
- <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
- <property name="prefix">
- <value>/WEB-INF/views/</value>
- </property>
- <property name="suffix">
- <value>.jsp</value>
- </property>
- </bean>
- </list>
- </property>
- <property name="defaultViews">
- <list>
- <!-- for application/json -->
- <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
- <!-- prevent JSON Hijacking -->
- <property name="prefixJson" value="false" />
- </bean>
- </list>
- </property>
- </bean>
-
- <!-- 开启注解模式 -->
- <mvc:annotation-driven/>
- </beans>
|