后台執行importExcel,明明方法執行成功,但是前台卻提示404
@RequestMapping("/import")
public Json importExcel(@RequestParam(value="file", required=true) CommonsMultipartFile file,HttpServletRequest req, String exp1 , String modelType){
String[] str=commonServiceI.GetObjectId(3, req);
//str[0]createBy str[1]createDepartment str[2]createArea
List<TjSamilarDto> ltj = tbLicencePorductService.importData(file,exp1,modelType , str[0],str[1],str[2]);
/*String path = "";
if(modelType.equals("危險化學品安全生產許可證")){
path = "/license/ChemicalsPorduct";
}else if(modelType.equals("危險化學品安全使用許可證")){
path ="/license/ChemicalsUse";
}
return path; */
Json j = new Json();
if(ltj.isEmpty()){
j.setExp1("0");
j.setMsg("導入成功!");
}else{
j.setExp1("1");
j.setMsg("有"+ltj.size()+"條數據因與系統中企業名稱不匹配導致未導入成功,是否下載查看!");
}
j.setList(ltj);
j.setSuccess(true);
return j;
}
原因:
注解@ResponseBody的作用,這個注解的作用是將函數返回值作為請求返回值。
沒有這個注解的話,請求的響應應該是一個頁面,不需要頁面的話應該加上這個注解。