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.

82 lines
3.2 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">
<!-- 启用组件扫描和自动装配 -->
<context:component-scan base-package="org.example.controller"/>
<!-- 启用Spring MVC注解编程模式 -->
<mvc:annotation-driven/>
<!-- 配置拦截器链 -->
<!-- 配置拦截器链 -->
<mvc:interceptors>
<!-- 配置第1个拦截器 -->
<mvc:interceptor>
<!-- 1. 拦截的路径 -->
<mvc:mapping path="/user/**" />
<mvc:mapping path="/uploadfile/**" />
<mvc:mapping path="/role/**" />
<mvc:mapping path="/dept/**" />
<mvc:mapping path="/notice/**" />
<mvc:mapping path="/job/**" />
<mvc:mapping path="/employee/**" />
<mvc:mapping path="/main/**" />
<!-- 2. 例外的路径,不拦截的路径,即白名单 -->
<mvc:exclude-mapping path="/user/handle_reg.do" />
<mvc:exclude-mapping path="/user/login.do" />
<mvc:exclude-mapping path="/user/handle_login.do" />
<mvc:exclude-mapping path="/user/getCaptcha.do" />
<mvc:exclude-mapping path="/user/verify.do" />
<mvc:exclude-mapping path="/user/exit.do" />
<!-- 3. 指定拦截器类 -->
<bean class="org.example.interceptor.LoginInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<!--配置模板引擎-->
<bean id="springResourceTemplateResolver" class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/WEB-INF/templates/"/>
<property name="suffix" value=".html"/>
<!--解决页面的中文乱码-->
<property name="characterEncoding" value="UTF-8"/>
<property name="order" value="1"/>
<property name="templateMode" value="HTML5"/>
<property name="cacheable" value="false"/>
</bean>
<bean id="springTemplateEngine" class="org.thymeleaf.spring5.SpringTemplateEngine">
<property name="templateResolver" ref="springResourceTemplateResolver"/>
</bean>
<!-- 配置thymeleaf视图解析器 -->
<bean id="thymeleafViewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
<property name="templateEngine" ref="springTemplateEngine"/>
<property name="characterEncoding" value="UTF-8"/>
</bean>
<!-- 启用JSP视图解析器 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/"/>
<property name="suffix" value=".html"/>
</bean>
<!-- 启用文件上传解析器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- the maximum file size in bytes : 10m -->
<property name="maxUploadSize" value="10485760"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
</beans>