kindeditor调用springmvc接口上传文件的代码
解决方法:
@RequestMapping("${trainAndEducate}/uploadKindeditorFile")
public void uploadKindeditorFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String,Object> result= new HashMap<String, Object>();
// 转型为MultipartHttpRequest:
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
// 获得文件:
MultipartFile file= multipartRequest.getFile("imgFile");
//上传文件的代码省略。。。
result.put("error", 0);
result.put("url", "上传文件的相对路径");
//解决跨域的代码:http://yayihouse.com/yayishuwu/chapter/2506
PrintWriter writer = response.getWriter();
writer.println(JSON.toJSONString(result));
}