标签:name rem app 后台 ssd htm for click cli
html:
<div id="test">
<form id="uploadForm"><!--这里我没有添加enctype="multipart/form-data",也可以使用,没有出问题-->
<input type="file" name="testFile" value="选择文件">
<input type="button" value="添加" id="mikasa">
</form>
</div>
js:
<script type="text/javascript">
$("#mikasa").click(function(){
$("#test div").remove();
var formData = new FormData($( "#uploadForm" )[0]);
$.ajax({
url: ‘/aToB‘ ,
type: ‘POST‘,
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (returndata) {
$("#test").append(returndata);
},
error: function (returndata) {
alert("出错了");
}
});
});
</script>
后台:
@RequestMapping("/aToB")
@ResponseBody
public String aToBl(@RequestParam("testFile")MultipartFile multipartFile) throws Exception {
InputStream inputStream = multipartFile.getInputStream();
return "xxx";
}
标签:name rem app 后台 ssd htm for click cli
原文地址:http://www.cnblogs.com/SweetTooth/p/7867309.html