使用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>
