关于文件的上传的下载报400无法请求的错误
错误内容

文件的上传:spring-mvc.xml里配置了
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 请求的编码格式 必须和jsp的pageEncoding属性一致 以便正确读取表单的内容 默认为ISO-8859-1 -->
<property name="defaultEncoding" value="UTF-8"></property>
<!-- 上传文件大小上限 单位为字节 (10485760=10M) -->
<property name="maxUploadSize" value="10485760"></property>
<property name="maxInMemorySize" value="40960"></property>
</bean>
然后在
public String register(@Valid Admin1 admin, HttpServletRequest request, HttpSession session, HttpServletResponse response,
@RequestParam("adminPhotoPath1")CommonsMultipartFile file) throws IOException {
在jsp里:
<label for="adminPhotoPath">证件照</label>
<input type="file" name="adminPhotoPath1" id="adminPhotoPath" >
注意:报错原因是input里的name写成了adminPhotoPath,controller里接收的也是adminPhotoPath,同样pojo里面也有个叫String adminPhotoPath;这个同时也是属性的值,可能不能这样同时写属性的值进去!!!上面写的是非adminPhotoPath,就可以运行。

浙公网安备 33010602011771号