web项目使用kindeditor富文本上传图片时报一个异常

兼爱 2015-11-05 11:31:41

报错的9行和108行, 分别是jsp页面的java代码段起始符号(<%)和结束符号(%>), 一番捣鼓, 一番fuck, 加上查询资料, 没有什么收获,刚才新建了一个web项目, 加入kindeditor,完全可以上传图片, 我需要使用的项目是spring+springMVC+hibernate+maven, 如果有哪位哥哥知道这是什么情况, 还望助我搞定之... 困得不行了...


以下为报错信息

HTTP ERROR 500
Problem accessing /resources/editor/jsp/upload_json.jsp. Reason:

PWC6033: Unable to compile class for JSP

PWC6197: An error occurred at line: 108 in the jsp file: /resources/editor/jsp/upload_json.jsp
PWC6199: Generated servlet error:
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

PWC6197: An error occurred at line: 9 in the jsp file: /resources/editor/jsp/upload_json.jsp
PWC6199: Generated servlet error:
Arrays cannot be resolved

Caused by:

org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP

PWC6197: An error occurred at line: 108 in the jsp file: /resources/editor/jsp/upload_json.jsp
PWC6199: Generated servlet error:
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

PWC6197: An error occurred at line: 9 in the jsp file: /resources/editor/jsp/upload_json.jsp
PWC6199: Generated servlet error:
Arrays cannot be resolved


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:123)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:296)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:376)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:360)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:527)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:421)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:493)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:930)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:358)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:866)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
at org.eclipse.jetty.server.Server.handle(Server.java:351)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:594)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1059)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:764)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:211)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:506)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
at java.lang.Thread.run(Thread.java:745)
Powered by Jetty://



...全文
138 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
兼爱 2015-11-08
引用 4 楼 baidu_32608009 的回复:
有问题QQ549017122
换上你的后, 还是报了错, 信息如下, 我自己摸索着用tomcat试了下, 居然可以用, 不过换成tomcat的话, 改动的地方太多了 HTTP ERROR 500 Problem accessing /editor/jsp/upload_json.jsp. Reason: PWC6033: Unable to compile class for JSP PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files PWC6199: Generated servlet error: The import java.util.Arrays cannot be resolved Caused by: org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files PWC6199: Generated servlet error: The import java.util.Arrays cannot be resolved at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:123) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:296) at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:376) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:437) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:360) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:527) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:423) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:493) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:930) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:358) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:866) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113) at org.eclipse.jetty.server.Server.handle(Server.java:351) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:594) at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1059) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:764) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217) at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:506) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436) at java.lang.Thread.run(Unknown Source) Powered by Jetty://
回复
兔子托尼啊 2015-11-06
不能 PWC6197: An error occurred at line: 108 in the jsp file: /resources/editor/jsp/upload_json.jsp PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files PWC6197: An error occurred at line: 9 in the jsp file: /resources/editor/jsp/upload_json.jsp PWC6199: Generated servlet error: Arrays cannot be resolved 你怎么写的? 有异常信息吗
回复
baidu_32608009 2015-11-06
有问题QQ549017122
回复
baidu_32608009 2015-11-06
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.Random"%> <%@page import="java.util.Arrays"%> <%@page import="java.util.Iterator"%> <%@page import="java.util.List"%> <%@page import="java.util.Date"%> <%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%> <%@page import="java.io.File"%> <%@page import="java.util.Map"%> <%@page import="java.util.HashMap"%> <%@ page import="java.text.SimpleDateFormat" %> <%@ page import="org.apache.commons.fileupload.*" %> <%@ page import="org.apache.commons.fileupload.disk.*" %> <%@ page import="org.json.simple.*" %> <% /** * KindEditor JSP * * 本JSP程序是演示程序,建议不要直接在实际项目中使用。 * 如果您确定直接使用本程序,使用之前请仔细确认相关安全设置。 * */ //文件保存目录路径 String savePath = pageContext.getServletContext().getRealPath("/") + "attached/"; //文件保存目录URL String saveUrl = request.getContextPath() + "/attached/"; //定义允许上传的文件扩展名 HashMap extMap = new HashMap(); extMap.put("image", "gif,jpg,jpeg,png,bmp"); extMap.put("flash", "swf,flv"); extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb"); extMap.put("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2"); //最大文件大小 long maxSize = 1000000; response.setContentType("text/html; charset=UTF-8"); if(!ServletFileUpload.isMultipartContent(request)){ out.println(getError("请选择文件。")); return; } //检查目录 File uploadDir = new File(savePath); if(!uploadDir.isDirectory()){ out.println(getError("上传目录不存在。")); return; } //检查目录写权限 if(!uploadDir.canWrite()){ out.println(getError("上传目录没有写权限。")); return; } String dirName = request.getParameter("dir"); if (dirName == null) { dirName = "image"; } if(!extMap.containsKey(dirName)){ out.println(getError("目录名不正确。")); return; } //创建文件夹 savePath += dirName + "/"; saveUrl += dirName + "/"; File saveDirFile = new File(savePath); if (!saveDirFile.exists()) { saveDirFile.mkdirs(); } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String ymd = sdf.format(new Date()); savePath += ymd + "/"; saveUrl += ymd + "/"; File dirFile = new File(savePath); if (!dirFile.exists()) { dirFile.mkdirs(); } FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); upload.setHeaderEncoding("UTF-8"); List items = upload.parseRequest(request); Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); String fileName = item.getName(); long fileSize = item.getSize(); if (!item.isFormField()) { //检查文件大小 if(item.getSize() > maxSize){ out.println(getError("上传文件大小超过限制。")); return; } //检查扩展名 String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(); /*if(!Arrays.asList(((String)extMap.get(dirName)).split(",")).contains(fileExt)){ out.println(getError("上传文件扩展名是不允许的扩展名。\n只允许" + extMap.get(dirName) + "格式。")); return; } */ SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt; try{ File uploadedFile = new File(savePath, newFileName); item.write(uploadedFile); }catch(Exception e){ out.println(getError("上传文件失败。")); return; } out.println("{\"error\":\"1\",\"message\":\""+saveUrl + newFileName+"\"}"); } } %> <%! private String getError(String message) { return "{\"error\":\"1\",\"message\":\""+message+"\"}"; } %>
回复
兼爱 2015-11-06
引用 1 楼 rui888 的回复:
不能 PWC6197: An error occurred at line: 108 in the jsp file: /resources/editor/jsp/upload_json.jsp PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files PWC6197: An error occurred at line: 9 in the jsp file: /resources/editor/jsp/upload_json.jsp PWC6199: Generated servlet error: Arrays cannot be resolved 你怎么写的? 有异常信息吗
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-11-05 11:31
社区公告
暂无公告