Spring 3.1 에서 Converter가 적용이 안되고 있습니다;;

415 views
Skip to first unread message

나이뽀리

unread,
Jun 20, 2012, 3:13:43 AM6/20/12
to Korea Spring User Group
컨버터를 만들어서 등록을 하려고 하면
typeMismatch가 나면서 Binding을 할 수 없어서 문의드립니다.
sts에서 spring template project로 'MVC' 프로젝트를 생성을 해서 사용하다 보니
설정들이 혼재해 있어 그런건가요?


root-context.xml
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

<!-- Formatting Conversion -->
<bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean" /
>

<!-- Converter -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean
class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer" /
>
</property>
</bean>
<bean
class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService" ref="conversionService" />
</bean>


servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<annotation-driven />
<annotation-driven conversion-service="conversionService" />
<context:component-scan base-package="com.XXX" />

<!-- Cache -->
<cache:annotation-driven />

<!-- Converter -->
<beans:bean id="conversionService"
class="org.springframework.context.support.ConversionServiceFactoryBean">
<beans:property name="converters">
<beans:list>
<beans:bean class="com.XXX.common.convertor.CodeToString" />
<beans:bean class="com.XXX.common.convertor.StringToCode" />
<beans:bean class="com.XXX.common.convertor.CodeGroupToString" />
<beans:bean class="com.XXX.common.convertor.StringToCodeGroup" />
</beans:list>
</beans:property>
</beans:bean>


root.context.xml의 3.1.1 reference 문서 참고하여
'FormattingConversionServiceFactoryBean' 안에다 설정을 해보기도 하고 지워보기도 하고
root와 servlet를 서로 바꿔가면서 설정을 해봐도
컨버터가 적용이 안됩니다.

아무래도 component-scan 선언 부분이 문제인거 같은데
해결 방법을 찾을 수 없어 문의해봅니다;;

SooRim Sun

unread,
Jun 20, 2012, 4:21:44 AM6/20/12
to ks...@googlegroups.com
맨 위에  mvc <annotation-driven /> 을  중복 설정하셨는데요. 제거해야 하지 않을까요... 




2012년 6월 20일 오후 4:13, 나이뽀리 <nif...@gmail.com>님의 말:
 <annotation-driven />

나이뽀리

unread,
Jun 20, 2012, 7:05:56 AM6/20/12
to Korea Spring User Group
수정하다가 저게 남아있었네요;;
감사합니다.


On 6월20일, 오후5시21분, SooRim Sun <soorim....@gmail.com> wrote:
> 맨 위에 mvc <annotation-driven /> 을 중복 설정하셨는데요. 제거해야 하지 않을까요...
>

> 2012년 6월 20일 오후 4:13, 나이뽀리 <nife...@gmail.com>님의 말:
>
>
>
>
>
>
>
> > <annotation-driven />

Reply all
Reply to author
Forward
0 new messages