在springMVC框架下,同一form上传和传文本,如何实现

Poom_soFt 2017-12-29 03:50:22
form中用enctype="multipart/form-data",model 获得不到值,查了其他方法,
在spring.xml中配置
<bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver">  
<property name="maxUploadSize" value="1024000000"/>
<property name="resolveLazily" value="true"/>
<property name="maxInMemorySize" value="4096"/>
</bean>
也不行,求大神帮忙看看
...全文
459 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Poom_soFt 2018-01-02
  • 打赏
  • 举报
回复
引用 3 楼 qq_41228556 的回复:
你搜一下formData,
引用 4 楼 vswen5 的回复:
用MultipartFile试试
我标题没写明白 : 主要是 在做上传文件图片 和 文本(text等) 同时上传,如何在同一form中一起提交, 加了这个属性enctype="multipart/form-data" 之后,后台model里为null,我想问如何解决这一问题,
<form action="commdity/upload" method="post" enctype="multipart/form-data">
     	    <font class="alps">商品名称    </font><input type="text" class="oText" name="cname"><br><br>
     	    <font class="alps">商品价格    </font><input type="text" class="oText" name="cprice"><br><br>
     	    <font class="alps">商品子类    </font><input type="text" class="oText" name="ctype"><br><br>
     	    <font class="alps">商品库存    </font><input type="text" class="oText" name="cnum"><br><br>
     	    <font class="alps">商品简介    </font><input type="text" class="oText" name="cproperty"><br><br>
     	    <font class="alps">商品产地    </font><input type="text" class="oText" name="cplace"><br><br>
     	    <font class="alps">商品星级    </font><input type="text" class="oText" name="cstar"><br><br>
     	    <font class="alps">商品主类    </font><input type="text" class="oText" name="cparenttype"><br><br>
     	    <font class="alps">选择图片    </font><input type="file" class="oText" name="fileName" id="inputs"><br><br>
     	    <div id='dd'></div><br><br>
     	    <input type="submit" class="oText" value="保存"><br><br>
     </form>
vswen5 2018-01-02
  • 打赏
  • 举报
回复 1
用MultipartFile试试
qq_41228556 2018-01-02
  • 打赏
  • 举报
回复
你搜一下formData,
Poom_soFt 2018-01-02
  • 打赏
  • 举报
回复
引用 1 楼 qq_39241047 的回复:
id="multipartResolver" 加上去试试
加在bean标签后面吗?(加了没效果)
Poom_soFt 2018-01-02
  • 打赏
  • 举报
回复
引用 6 楼 qq_41228556 的回复:
var form = new FormData(document.querySelector("#Form1")); $.ajax({ url: 你的url, type: "POST", data: form , cache:false, processData: false, // 不处理数据 contentType: false, // 不设置内容类型 success:function(dt){ } });
还是不行
qq_41228556 2018-01-02
  • 打赏
  • 举报
回复
var form = new FormData(document.querySelector("#Form1")); $.ajax({ url: 你的url, type: "POST", data: form , cache:false, processData: false, // 不处理数据 contentType: false, // 不设置内容类型 success:function(dt){ } });
qq_39241047 2017-12-29
  • 打赏
  • 举报
回复
id="multipartResolver" 加上去试试

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧