Spring 3.2 에서 기존에서와 같이 ContentNegotiatingViewResolver 를 사용하였는데 오류가 발생..
mediaType 을 캐스팅할 수 없다는 오류로, 환경구성에 문제가 있는줄 알고 이틀간을 파악하였으나...황당하게도 Spring 3.2 로 오면서 ContentNegotiatingViewResolver 적용 방법이 바뀐것을 확인...(최신버젼을 사용하면 고생이라는 말이 괜히 나온게 아니다 ㅠ.ㅠ)
1. 아래는 Spring Framework 3.2 이전 설정 방법.
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html">
<entry key="xml" value="application/xml">
</entry></entry></map>
</property>
<property name="order" value="0">
</property></bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="1">
<property name="prefix" value="/WEB-INF/jsp/">
<property name="suffix" value=".jsp">
</property></property></property></bean>
2. 아래가 Spring Framework 3.2 에서 org.springframework.web.accept.ContentNegotiationManager 을 통해 설정하는 방법. <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="order" value="1">
<property name="contentNegotiationManager">
<bean class="org.springframework.web.accept.ContentNegotiationManager">
<constructor-arg>
<bean class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
<constructor-arg>
<map>
<entry key="json" value="application/json">
<entry key="jsonp" value="javascript/jsonp">
<entry key="xml" value="application/xml">
</entry></entry></entry></map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</property>
<property name="defaultViews">
<list>
<!-- JSON View -->
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
<!-- JSONP view -->
<bean class="com.wemoss.common.view.JSONPView">
<property name="contentType" value="javascript/jsonp">
</property></bean>
<!-- XML View -->
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg>
<bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="packagesToScan">
<list>
<value>documentLoader.domain</value>
</list>
</property>
</bean>
</constructor-arg>
</bean>
</bean></list>
</property>
</property></bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="2">
<property name="prefix" value="/WEB-INF/jsp/">
<property name="suffix" value=".jsp">
</property></property></property></bean>
얼리어댑터 정신을 소프트웨어 개발에 적용하면 고생할 뿐이다...ㅠ.ㅠ