/** * 添加下载图片配置 * @throws IOException */ @RequestMapping(value = "/grid/imgconf/addimgconf",method = {RequestMethod.POST, RequestMethod.GET},produces = {"text/html;charset=UTF-8"}) @ResponseBody public String addImgConf(HttpServletRequest request, HttpServletResponse response, BindException errors) throws IOException{ String m = "00"; MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); response.setHeader("Access-Control-Allow-Origin", "*"); String projectid = Function.dealNull(multipartRequest.getParameter("projectid")); String viewKey = Function.dealNull(multipartRequest.getParameter("viewkey")); String type = Function.dealNull(multipartRequest.getParameter("type")); String remark = Function.dealNull(multipartRequest.getParameter("remark")); try { //唯一性判断 int size = imgConfService.getImgConfsCount(Constants.DEF_STRING_NULL, projectid, viewKey, Constants.STATUS_ON); if(size > 0){ m = "02"; logger.info("已存在的控件标识!"); return "<textarea>" + m + "</textarea>"; } //上传图片 Map<String, String> picInfo = imgConfService.uploadImage(fileMap); imgConfService.addImgConf(UUID.randomUUID().toString(), projectid, viewKey, type, remark, picInfo.get("URL"), Constants.STATUS_ON); m = "00"; logger.info("添加下载图片配置成功!"); } catch (Exception e) { m = "01"; logger.error("添加下载图片配置失败" ,e); }
//加<textarea>以解决IE下submit后没有执行回调success函数,这个是jquery easyui form的bug
return "<textarea>" + m + "</textarea>";
}
说明:"<textarea>" + m + "</textarea>";和produces = {"text/html;charset=UTF-8"}解决IE下不能执行回调函数success的问题
以上这篇form+iframe解决跨域上传文件的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章: