<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 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/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <!-- 配置springmvc的组件 --> <context:component-scan base-package="cn.immoc"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/> </context:component-scan> <!-- <mvc:resources location="/images/" mapping="/images/**"></mvc:resources> <mvc:resources location="/img/" mapping="/img/**"></mvc:resources> --> <mvc:resources location="/js/" mapping="/js/**"></mvc:resources> <mvc:resources location="/style/" mapping="/style/**"></mvc:resources> <!-- http请求映射 --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="cacheSeconds" value="0"/> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter"/> <ref bean="mappingStringHttpMessageConverter"/> </list> </property> <property name="webBindingInitializer" ref="webBindingInitializer"/> </bean> <!-- 配置视图解析器 --> <bean class=" org.springframework.web.servlet.view.ContentNegotiatingViewResolver" id="viewResolver"> <property name="ignoreAcceptHeader" value="true"></property> <property name="mediaType"> <map> <entry key="json" value="application/json"></entry> <entry key="xml" value="application/xml"></entry> </map> </property> <property name="defaultContentType" value="text/html"/> <property name="favorParamter" value="false"/> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="order" value="2"/> <property name="prefix" value="/WEB-INF/views"/> <property name="suffix" value=".jsp"/> </bean> </list> </property> </bean> </beans>