如何配置MultipartResolver?

时间:2012-07-16 06:24:43

标签: spring-mvc

<?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配置时,我收到以下错误:

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

请帮助我,我是春天的新手。

1 个答案:

答案 0 :(得分:7)

我认为你应该beanproperty添加beans前缀:

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

并记得使用结束标记关闭XML:

...
</beans:beans>