You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.9 KiB
91 lines
3.9 KiB
<?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:mvc="http://www.springframework.org/schema/mvc"
|
|
xsi:schemaLocation="
|
|
http://www.springframework.org/schema/beans
|
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
http://www.springframework.org/schema/context
|
|
http://www.springframework.org/schema/context/spring-context.xsd
|
|
http://www.springframework.org/schema/mvc
|
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
|
<!--spring-mvc的配置文件 这个文件主要配置网站跳转逻辑的控制,配置-->
|
|
<!-- 扫描组件 控制器 -->
|
|
<context:component-scan base-package="comxyp.controller"></context:component-scan>
|
|
<!--视图解析器配置-->
|
|
<bean id="resourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
|
<property name="prefix" value="/WEB-INF/page/admin/"></property>
|
|
<property name="suffix" value=".jsp"></property>
|
|
</bean>
|
|
|
|
<!--设置文件上传核心组件-->
|
|
<!--id值必须是multipartResolver 这个是规定的-->
|
|
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
|
</bean>
|
|
|
|
|
|
<!--两个标准的配置-->
|
|
<!--将spring-mvc不能处理的请求交给tomcat 开启静态资源的访问-->
|
|
<mvc:default-servlet-handler></mvc:default-servlet-handler>
|
|
|
|
<!--拦截器配置-->
|
|
<mvc:interceptors>
|
|
<mvc:interceptor>
|
|
<!--拦截所有以/admin/开头的访问路径-->
|
|
<mvc:mapping path="/admin/**"></mvc:mapping>
|
|
<!--排除员工登录 注册的访问路径-->
|
|
<mvc:exclude-mapping path="/admin/employee/login"/>
|
|
<mvc:exclude-mapping path="/admin/login.html"/>
|
|
<mvc:exclude-mapping path="/admin/employee/register"/>
|
|
<mvc:exclude-mapping path="/admin/register.html"/>
|
|
<!--注入拦截-->
|
|
<bean class="comxyp.interceptor.LoginInterceptor"></bean>
|
|
</mvc:interceptor>
|
|
</mvc:interceptors>
|
|
<!--配置mvc注解驱动-->
|
|
<!--能支持springmvc更高级的一些功能 JSR303校验 ajax等-->
|
|
<mvc:annotation-driven>
|
|
<mvc:message-converters>
|
|
<!--@ResponseBody 中文响应乱码 -->
|
|
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
|
|
<property name="supportedMediaTypes">
|
|
<list>
|
|
<value>
|
|
text/plain;charset=UTF-8
|
|
</value>
|
|
<value>
|
|
text/html;charset=UTF-8
|
|
</value>
|
|
|
|
<value>
|
|
application/json;charset=UTF-8
|
|
</value>
|
|
<value>
|
|
application/x-www-form-urlencoded;charset=UTF-8
|
|
</value>
|
|
</list>
|
|
</property>
|
|
</bean>
|
|
|
|
|
|
<!-- JSON中文请求乱码及解决
|
|
HttpMediaTypeNotAcceptableException: Could not find acceptable representation 异常信息-->
|
|
<bean id="jacksonMessageConverter"
|
|
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
|
|
<property name="supportedMediaTypes">
|
|
<list>
|
|
<value>
|
|
application/json;charset=UTF-8
|
|
</value>
|
|
<value>
|
|
application/x-www-form-urlencoded;charset=UTF-8
|
|
</value>
|
|
</list>
|
|
</property>
|
|
</bean>
|
|
</mvc:message-converters>
|
|
</mvc:annotation-driven>
|
|
|
|
|
|
</beans> |