IDEA環境下SSM整合------環境配置
阿新 • • 發佈:2018-12-09
<?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-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <!-- 包含:webBean ViewResolver、handlerAdapter controller handlerMapping--> <!-- 配置自定義掃描的包 --> <context:component-scan base-package="com.cmos.controller,com.cmos.service,com.cmos.dao"/> <!-- 配置檢視解析器:如何把handler方法返回值解析為實際的物理檢視 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/views/"> </property> <property name="suffix" value=".jsp"> </property> </bean> <!-- default-servlet-handler 會在SpringMvc 上下文中定義一個DefaultServletHttpRequestHandler, 它會對進入DispatcherServlet的請求進行篩查,如果發現沒有經過對映的請求,就將該請求交由web應用伺服器 預設的Servlet處理,如果不是靜態資源則用DispathcerServlet進行處理 --> <mvc:default-servlet-handler/> <mvc:annotation-driven> </mvc:annotation-driven> <!--攔截器--> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/district"/> <mvc:mapping path="/organization"/> <mvc:mapping path="/unit"/> <mvc:mapping path="/student"/> <!--com.coms...是我專案的包的名稱不要誤解 --> <bean class="com.cmos.handlers.MyInterceptor"></bean> </mvc:interceptor> </mvc:interceptors> <!-- 配置SimpleMappingExceptionResolver --> <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key="java.lang.ArrayIndexOutOfBoundsException">error</prop> </props> </property> </bean> </beans>