The Ajax form submission method can serialize the form form and submit the data to the background through data, for example:
$.ajax({
url : "http://localhost:8080/",
type : "POST",
data : $( '#postForm').serialize(),
success : function(data) {
},
error : function(data) {
}
});
Workaround: Use FormData. It is best to use jquery here and it should not be supported before version 2.0. E.g:
<form id="form"> <P class="p5"><span><i>*</i>商户证书:</span> <input type='text' name='apiclientType' id='textfield' class='w_txt' > <input type='button' class='w_btn' value='上传证书' /> <input type="file" name="fileField" class="w_file"id="fileField" size="28" onchange="
document.getElementById('textfield').value=this.value" />
</P>
</form>
var formData = new FormData(document.getElementById("form"));//表单id$.ajax({
url: '${ctx}/wmManage/saveWeixinConfig.do' ,
type: 'POST',data: formData,async: false,cache: false,contentType: false,processData: false,success: function
(result) {
}
});
附上后台数据接收:
@RequestMapping("/saveWeixinConfig")@ResponseBody
public ResultMsg saveWeixinConfig(@RequestParam(value = "fileField",required = false)MultipartFile fileField) throws IOException {
return "";
}