【问题标题】:How to configure MultipartResolver?如何配置 MultipartResolver?
【发布时间】:2012-07-16 14:53:14
【问题描述】:
<?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'.".

请帮帮我,我是 spring 新手。

【问题讨论】:

    标签: spring-mvc


    【解决方案1】:

    我认为你应该在beanproperty 前加上beans

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

    记得用结束标签关闭 XML:

    ...
    </beans:beans>
    

    【讨论】:

    • 这个答案仍然有效,这是因为 OP 使用的 Spring 版本比他复制和粘贴的示例更新版本。 (就像我一样!)
    猜你喜欢
    • 2014-06-27
    • 1970-01-01
    • 2012-11-23
    • 2012-06-20
    • 2011-09-30
    • 1970-01-01
    • 2015-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多