2014-03-04 36 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

謝謝你,確切的問題。 –