web.xml容器中配置编码的过滤和单一控制器的设置,以及初始化Spring容器

<!-- 加载Spring容器配置 -->
  

<!-- 配置前端单一控制器 -->
<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<!-- 加载spring容器 -->
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc2.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

 

<!-- 加载SpringMVC容器配置 -->

 

<!-- 开启注解路径映射 -->
<mvc:annotation-driven />
<!-- 开启注解扫描bean,注解方式管理bean对象 -->
<context:component-scan base-package="com.auto" />
<!-- 配置请求派发的组件,派发对应的自控制器 -->
<!--对静态资源文件image的访问-->
<mvc:resources mapping="/image/*" location="/image/" />
<!-- 配置视图解析处理器ViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<util:properties id="jdbc" location="classpath:com/auto/dbutil/dbconfig.properties" />
<!-- 配置拦截器 -->
<mvc:interceptors>
<mvc:interceptor>
<!-- 指定被拦截的请求 -->
<mvc:mapping path="/login/*"/>
<!-- 不被拦截的请求 -->
<mvc:exclude-mapping path="/user/*"/>
<bean class="com.auto.control.TestHandlerInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
<!-- Spring容器捕获异常 -->
<!--
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception ">error</prop>
<prop key="com.auto.TimeoutException">login</prop>
</props>
</property>
</bean>
-->
<bean class="com.auto.control.MyHandleException"></bean>

posted @ 2018-03-20 16:59  傲云萧雨  阅读(339)  评论(0编辑  收藏  举报