多个视图解析器的优先级问题 ,暂时如下,有待继续深入了解
<?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">
<!--<mvc:resources mapping="/resources/**" location="/resources/" />-->
<!--<mvc:resources mapping="/src/**" location="/src/" />-->
<mvc:default-servlet-handler/>
<mvc:annotation-driven/>
<context:component-scan base-package="com.smart.web"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="100"/>
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!--<bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" id="multipartResolver"/>-->
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
<property name="order" value="0"/>
</bean>
<bean id="userListExcel" class="com.smart.view.UserExcelView" />
<bean id="userListPdf" class="com.smart.view.UserPdfView"/>
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/view/ftl/"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="freemarkerSettings">
<props>
<prop key="classic_compatible">true</prop>
</props>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver" id="freeMarkerViewResolver">
<property name="order" value="20"/>
<!--<property name="prefix" value="/WEB-INF/ftl/"/>-->
<property name="suffix" value=".ftl"/>
<property name="contentType" value="text/html;charset=UTF-8"/>
</bean>
<bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean" id="contentNegotiationManager">
<property name="ignoreAcceptHeader" value="true"/>
<property name="favorParameter" value="true"/>
<property name="favorPathExtension" value="false"/>
<property name="parameterName" value="format"/>
<property name="defaultContentType" value="text/html"/>
<property name="mediaTypes">
<value>
html=text/html
xml=application/xml
json=application/json
</value>
</property>
</bean>
<bean id="userListXml" class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="modelKey" value="userList"/>
<property name="marshaller" ref="xmlMarshaller"/>
</bean>
<bean id="xmlMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="streamDriver">
<bean class="com.thoughtworks.xstream.io.xml.StaxDriver"/>
</property>
<property name="annotatedClasses">
<list>
<value>com.smart.domain.User</value>
</list>
</property>
</bean>
<bean id="userListJson" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="modelKey" value="userList"></property>
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"
id="userListMix">
<property name="order" value="1"/>
<property name="contentNegotiationManager" ref="contentNegotiationManager"/>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="modelKey" value="userList"/>
</bean>
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="modelKey" value="userList"/>
<property name="marshaller" ref="xmlMarshaller"/>
</bean>
</list>
</property>
</bean>
</beans>
jar包冲突问题 标签的使用
严重: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [file:/F:/yi/IDEA/workspace5/target/Spring-SpringMVC-Mybatis/WEB-INF/classes/spring.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.oxm</artifactId>
<version>3.2.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>org.springframework.beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework.core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>com.springsource.org.apache.commons.logging</artifactId>
<groupId>org.apache.commons</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>com.springsource.com.thoughtworks.xstream</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.8</version>
</dependency>