var options = {
cssPath : 'js/plugin/kindeditor/prettify.css',
filterMode : true,
uploadJson : baseUrl + '/js/plugin/kindeditor/jsp/upload_json.jsp',
filePostName: 'imgFile',//加上这个属性
afterUpload : function() {
this.sync()
},
items : []
};
editor = K.create('textarea[name="content"]', options);
//后台接收代码
@RequestMapping("/uploadimg")
public void uploadimg(@RequestParam(value = "imgFile", required = false) // value = js里面设置的 filePostName
MultipartFile file,HttpServletResponse response ) throws Exception {
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
处理逻辑代码
JSONObject obj = new JSONObject();
if( flag=1 ){//上传成功
obj.put("error", 0);
obj.put("url", "imageURL");
}else{
obj.put("error", 1);
obj.put("message", "msg");
}
//返回必须返回JSON
out.write(obj.toJSONString());
out.close();
}