2012-07-16 44 views
2
<?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" 
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> 

<!-- Enables the Spring MVC @Controller programming model --> 
<annotation-driven /> 

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources/ directory --> 
<resources mapping="/resources/**" location="/resources/" /> 
<bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" 
    id="multipartResolver"> <property name="maxUploadSize" value="500000" /> 
</bean> 

還有就是我的context.xml文件,但是當我包括multipartResolver配置我得到以下錯誤:如何配置MultipartResolver?

"cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'bean'.". 

請幫助我,我是新來的春天。

+1

沒有我的回答幫助你的? – jelies 2012-08-14 07:03:57

回答

6

我想你應該前綴beanpropertybeans

... 
<beans:bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" id="multipartResolver"> 
    <beans:property name="maxUploadSize" value="500000" /> 
</beans:bean> 
... 

,記得關閉與結束標記的XML:

... 
</beans:beans> 
+0

這個答案仍然有效,這是因爲OP使用的是比他複製和粘貼的例子更新版本的Spring。 (就像我!) – 2014-03-07 00:09:37