gistfile1.txt 文件导入,前台需要引入ajaxfileupload.js$.ajaxFileUpload({ url: 'importSubject', //用于文件上传的服务器端请求地址 type: 'post', secureuri: false, //是否需要安全协议,一般设置为false fileE
文件导入,前台需要引入ajaxfileupload.js $.ajaxFileUpload({ url: 'importSubject', //用于文件上传的服务器端请求地址 type: 'post', secureuri: false, //是否需要安全协议,一般设置为false fileElementId: $("input[name='uploadExcel']").attr("id"),//文件上传域的ID contentType : false,// 告诉jQuery不要去设置Content-Type请求头 data:{ sid:$("#sid").val(), billNum:$("#billnum").val(), batchId:batchId }, dataType: 'json', //返回值类型 一般设置为json success: function (data, status){ //服务器成功响应处理函数 $('#ftkm').datagrid('loadData',{total:0,rows:[]}); $('#ftkm').datagrid({ data:data }); $('#ReportKM').window('close'); }, error: function (data, status, e){//服务器响应失败处理函数 alert(e); } }); 后台java类接收 /** * 导入excel * @param request * @return * @throws Exception */ @RequestMapping(value = "/importSubject", method = RequestMethod.POST) @ResponseBody public Object reportSubject(HttpServletRequest request, @RequestParam(value = "uploadExcel", required = false) MultipartFile uploadExcel, @RequestParam String batchId, @RequestParam String billNum, HttpServletResponse response ) throws Exception{ ModelAndView ret = new ModelAndView(); InputStream in = null; try{ List