SSM中 spring-mvc.xml 配置文件

<!--扫描控制器包-->

<context:component-scan base-package="<!--控制器包所在路径-->"></context:component-scan>

<!--指定以注解的方式配置spring mvc-->
<!--相当于声明了
处理器映射器 RequestMappingHandlerMapping 怎么去找控制器的方式
处理器适配器 RequestMappingHandlerAdapter 什么样特征的java类是spring mvc的控制器
-->

<mvc:annotation-driven></mvc:annotation-driven>


<!--配置内置的jsp的视图解析器-->

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--配置视图的前缀-->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<!--配置视图的后缀-->
<property name="suffix" value=".jsp"></property>
</bean>

<!--&lt;!&ndash;配置拦截器&ndash;&gt;-->
<!--<mvc:interceptors>-->
<!--<bean id="loginInterceptor" class="com.aaa.ssm.interceptor.LoginInterceptor">-->
<!--&lt;!&ndash;在interceptor中定义一个allowUrls集合把所有允许通过的地址存放进去&ndash;&gt;-->
<!--&lt;!&ndash;放置所有不被该拦截器拦截的请求路径 需要生成getter与setter方法&ndash;&gt;-->
<!--<property name="allowUrls">-->
<!--<list>-->
<!--&lt;!&ndash;设置过滤拦截的方法,使其允许经过,不设置则不能登录&ndash;&gt;-->
<!--<value>/user/login.do</value>-->
<!--</list>-->
<!--</property>-->
<!--</bean>-->
<!--<bean id="permitInterceptor" class="com.aaa.ssm.interceptor.PermitInterceptor">-->
<!--<property name="allowUrls">-->
<!--<list>-->
<!--&lt;!&ndash;设置过滤拦截的方法,使其允许经过,不设置则不能登录&ndash;&gt;-->
<!--<value>/user/login.do</value>-->
<!--</list>-->
<!--</property>-->
<!--</bean>-->
<!--</mvc:interceptors>-->

<!--开启aop-->
<aop:config proxy-target-class="true"></aop:config>
<!--开始shiro的aop注解的支持-->
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"></property>
</bean>

<!--生命spring-mvc的统一异常处理页面-->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="../../error"></property>
</bean>
 
 
原文地址:https://www.cnblogs.com/LFY001023/p/10966743.html