2014-03-04 34 views
0

我想用spring的unmarshaller自动将请求体从xml解组到一个对象。但我没有得到错误util prfeix unbind。你能告诉我如何使用util:list以及我在哪里可以找到util:list的参考。我如何使用util:list在弹簧配置文件

我确实发现官方文档在</property中省略了关闭>,我在我的配置中更正了这一点。

我发现配置更令人沮丧,只是编写代码。

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> 
    <property name="messageConverters"> 
     <util:list id="beanList"> 
      <ref bean="stringHttpMessageConverter"/> 
      <ref bean="marshallingHttpMessageConverter"/> 
     </util:list> 
    </property 
</bean> 

<bean id="stringHttpMessageConverter" 
     class="org.springframework.http.converter.StringHttpMessageConverter"/> 

<bean id="marshallingHttpMessageConverter" 
     class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"> 
    <property name="marshaller" ref="castorMarshaller" /> 
    <property name="unmarshaller" ref="castorMarshaller" /> 
</bean> 

<bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"/> 

回答

1

您需要声明到util命名空间;例如:

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:util="http://www.springframework.org/schema/util" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> 
+0

谢谢你,确切的问题。 –