The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive re


使用SpringMVC,頁面跳轉時出現Bad Request:

信息如下:

Type Status Report

Message Required String parameter 'description' is not present

Description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

提示信息Message那里提及到的‘description’,它是上傳表單的其中一個參數,因為這個是第一個參數,所以只顯示了description。使用springmvc上傳文件功能時出現Bad Request,除了表單類型與@RequestParam POJO的屬性類型不一致導致的原因外,還有一個可能性原因,就是沒有配置MultipartResolver,因為springmvc默認情況下沒有裝配MultipartResolver,下面是配置MultipartResolver:

<!-- 配置上傳文件 -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize">
            <value>10485760</value>
        </property>
        <property name="defaultEncoding">
            <value>UTF-8</value>
        </property>
    </bean>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM