问题: 当前台jsp 页面form添加了 enctype="multipart/form-data" 后,后台controller 便获取不到, 去除这个enctype="multipart/form-data" 就可以将值传到 后台java 的controller 上
问题: 当前台jsp 页面form添加了 enctype="multipart/form-data" 后,后台controller 便获取不到, 去除这个enctype="multipart/form-data" 就可以将值传到 后台java 的controller 上
JSP :
<form:form id="photo" action="${ctx}/management/photo" method="post" enctype="multipart/form-data">
<input type="hidden" name="photoid" id="photoid" value="" />
<input type="text" name="title" id="title" value="" />
<input type="file" name="pathurl" id="pathurl" value="" />
</form:form>
java controller:
Java code
@RequestMapping(method=RequestMethod.POST)
public String create(ModelMap model,@Valid Photo photo,BindingResult errors,HttpServletRequest request,HttpServletResponse response) throws Exception {
System.out.println("create=====");
System.out.println(request.getAttribute("title"));
System.out.println(photo);
导入了:
com.springsource.org.apache.commons.io-1.4.0.jar
com.springsource.org.apache.commons.fileupload-1.2.1.jar
spring 的配置文件 写了:
XML code
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>104857600</value>
</property>
<property name="maxInMemorySize">
<value>4096</value>
</property>
</bean>
配置 应该没有错
你试试将 项目删除然后 再部署上去试试,我以前试过 缓存问题