FCKeditor在JSP中通过API方式实现图片和Flash的上传

11:05上午 三月 17, 2008 in category 工作 by 肖俊峰

  最近接触了一下FCKeditor,感觉非常不错,使用这个在线编辑器,编辑网站的内容非常轻松。我看了FCKeditor的JSP程序例子代码,JSP Sample 1 是通过API方式的示例,JSP Sample 2 是使用JSP Taglib的示例。我发现第一个例子上传图片和Flash就会出现错误,而第二个例子就不会。研究了下,发现使用了JSP Taglib的例子传递了参数,而API方式没有传递参数。

 看了下文档,发现参数的类是 FCKeditorConfigurations 。只要传递了合适的参数就可以了,下面是我的部分代码:

<%
String contextPath = request.getContextPath();
FCKeditor oFCKeditor ;
FCKeditorConfigurations fckCfg = new FCKeditorConfigurations();
fckCfg.put("ImageBrowserURL",contextPath+"/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector");
fckCfg.put("LinkBrowserURL",contextPath+"/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector");
fckCfg.put("FlashBrowserURL",contextPath+"/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector");
fckCfg.put("ImageUploadURL",contextPath+"/editor/filemanager/upload/simpleuploader?Type=Image");
fckCfg.put("LinkUploadURL",contextPath+"/editor/filemanager/upload/simpleuploader?Type=File");
fckCfg.put("FlashUploadURL",contextPath+"/editor/filemanager/upload/simpleuploader?Type=Flash");
oFCKeditor = new FCKeditor( request, "content" ) ;
oFCKeditor.setConfig(fckCfg);
oFCKeditor.setBasePath( request.getContextPath()+"/" ) ;
oFCKeditor.setValue( "" );
out.println( oFCKeditor.create() ) ;
%>

评论[0]

评论:

发表一条评论:
  • HTML语法: 启用