问题描述:
<form id="saveDeviceInfo" enctype="multipart/form-data" method="post" >
//.....
<div class="col-xs-6 ">
<span class="input-group-addon">附件上传</span>
<div class="xx_up" id="deviceAttachDiv">
<input type="file" name="deviceAttach" id="deviceAttach" />
</div>
</div>
</form>
在一个带有附件上传的form表单中,使用ajaxSubmit提交附件及表单,后台处理方法返回值为json对象,在ie8下出现request 的contentType和response 的contentType不一致,导致出现下载选项,
解决方案。
1、使用JSONObject.toJSONString处理返回值为string类型。
2、RequestMapping 注解中添加produces 属性,值为"text/plain; charset=utf-8"。
3、设置response的contentType属性同样为"text/plain; charset=utf-8"。