在本地调试正常。上传到服务器后,浏览器控制台报错:后台配置项返回格式出错,上传功能将不能正常使用!
打开ueditor.all.js
8094行:var config = isJsonp ? r:eval("("+r.responseText+")");
这句抛出异常。
打印isJsonp为false;
再打印r.responseText;
本地打印出:
{"videoMaxSize":102400000,"videoActionName":"uploadvideo","fileActionName":"uploadfile","fileManagerListPath":"/upload/file/","imageCompressBorder":1600,"imageManagerAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"imageManagerListPath":"/upload/image/","fileMaxSize":51200000,"fileManagerAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp",".flv",".swf",".mkv",".avi",".rm",".rmvb",".mpeg",".mpg",".ogg",".ogv",".mov",".wmv",".mp4",".webm",".mp3",".wav",".mid",".rar",".zip",".tar",".gz",".7z",".bz2",".cab",".iso",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".txt",".md",".xml"],"fileManagerActionName":"listfile","snapscreenInsertAlign":"none","scrawlActionName":"uploadscrawl","videoFieldName":"upfile","imageCompressEnable":true,"videoUrlPrefix":"/MulinArticle","fileManagerUrlPrefix":"/MulinArticle","catcherAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"imageManagerActionName":"listimage","snapscreenPathFormat":"/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","scrawlPathFormat":"/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","scrawlMaxSize":2048000,"imageInsertAlign":"none","catcherPathFormat":"/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","catcherMaxSize":2048000,"snapscreenUrlPrefix":"/MulinArticle","imagePathFormat":"/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","imageManagerUrlPrefix":"/MulinArticle","scrawlUrlPrefix":"/MulinArticle","scrawlFieldName":"upfile","imageMaxSize":2048000,"imageAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"snapscreenActionName":"uploadimage","catcherActionName":"catchimage","fileFieldName":"upfile","fileUrlPrefix":"/MulinArticle","imageManagerInsertAlign":"none","catcherLocalDomain":["127.0.0.1","localhost","img.baidu.com"],"filePathFormat":"/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}","videoPathFormat":"/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}","fileManagerListSize":20,"imageActionName":"uploadimage","imageFieldName":"upfile","imageUrlPrefix":"/MulinArticle","scrawlInsertAlign":"none","fileAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp",".flv",".swf",".mkv",".avi",".rm",".rmvb",".mpeg",".mpg",".ogg",".ogv",".mov",".wmv",".mp4",".webm",".mp3",".wav",".mid",".rar",".zip",".tar",".gz",".7z",".bz2",".cab",".iso",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".txt",".md",".xml"],"catcherUrlPrefix":"/MulinArticle","imageManagerListSize":20,"catcherFieldName":"source","videoAllowFiles":[".flv",".swf",".mkv",".avi",".rm",".rmvb",".mpeg",".mpg",".ogg",".ogv",".mov",".wmv",".mp4",".webm",".mp3",".wav",".mid"]}
服务器打印出:
<%@ page language="java" contentType="text/html; charset=UTF-8"
import="com.baidu.ueditor.ActionEnter"
pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%
request.setCharacterEncoding( "utf-8" );
response.setHeader("Content-Type" , "text/html");
String rootPath = application.getRealPath( "/" );
out.write( new ActionEnter( request, rootPath ).exec() );
%>
不知为何是这样的结果,有没有大神遇到过类似的问题?
出现这种问题有两种情况
1:config.json里面图片的路径需要改一下
2:你的项目有拦截器,导致它的某个jsp文件被拦截掉了。
打个断点吧,你有没有看后台有没有报错呢?
出现这种问题有两种情况
1:config.json里面图片的路径需要改一下
2:你的项目有拦截器,导致它的某个jsp文件被拦截掉了。
服务器上用的是x ampp,前端代码在htdocs里,后端代码在tomcat的webapps下,不是跨域问题吗?因为我总感觉是ueditor的jar包没有读取到
你这个问题我已经解决了,特来分享一下!你应该是在官方提供的jsp下的lib里 add to build path,这样是不行的,你需要将lib及相关jar包移到webInfo下面,这样百分百解决!亲测成功!
java+jsp
1、config.json配置不对
2、百度依赖的jar包没引入
3、请求controller.jsp的时候被你后台拦截了,或者是代码或者是nginx之类的,或者是拦截了以静态资源去访问了,因为这个文件在static下面,很多的nginx配置都是static下面的资源以静态资源访问,但是jsp不是静态资源。(我遇到的)