<script type="text/javascript" src="${ctxStatic}/js/jquery-form.js"></script>
$("#btnImportSubmit").click(function(){
var filepath = $("input[name='file']").val();
if(filepath!=""){
//ajaxFileUpload();
uploadPortraits();
}else{
CC.alert("没有要上传的文件!");
}
});
function uploadPortraits() {
var fileForm = $("#uploadForm");
var options = {
url:'${ctx}/customer/admin/FinancialDataCollection/upload',
type:'post',
success:function(data){
initData(data.resultData);
$("#file").val("");
},
error: function (data, status, e){
CC.alert("上传失败,请稍后在试!");
}
};
fileForm.ajaxSubmit(options);
}
<form:form id="uploadForm" action="${ctx}/customer/admin/FinancialDataCollection/upload" enctype="multipart/form-data"
method="post" ><div class="i-form-panel">
<div class="control-group">
<div class="controls col-sm-6">
<input type="file" name="file" id="file">
</div>
</div>
</div>
<div class="modal-footer">
<input id="btnImportSubmit" class="btn btn-primary" type="button" value="导 入"/>
<button class="btn i-btn btn-success" id="exportBtn" type="button">导入模板下载 </button>
<input id="btnSubmit" class="btn btn-primary" type="button" value="提交"/>
<input id="btnRefuse" class="btn btn-primary" type="button" value="拒绝"/>
</div>
<input type="hidden" id="id" value="${financialDataCollection.id }" name="id"/>
<label id="showResult"><font color='red'>${resultMsg}</font></label>
<label id="msgDetail"><font color='red'>${msgDetail}</font></label>
</form:form>
Controller层
public Map<String,Object> upload(@RequestParam("file") MultipartFile file,HttpServletRequest request,Model model){}
之前由于使用ajaxFileUpload插件进行Excel上传,由于某些原因不兼容IE11,所以使用此方法替换.