webwork2.2.2内置了fckeditor,用法
<ww:richtexteditor toolbarCanCollapse="false" width="700" label="描述" name="description"/> xwork.xml加入:
<package name="richtexteditor-browse" extends="webwork-default"
namespace="/webwork/richtexteditor/editor/filemanager/browser/default/connectors/jsp">
<action name="connector"
class="com.opensymphony.webwork.components.DefaultRichtexteditorConnector"
method="browse">
<result name="getFolders" type="richtexteditorGetFolders" />
<result name="getFoldersAndFiles"
type="richtexteditorGetFoldersAndFiles" />
<result name="createFolder" type="richtexteditorCreateFolder" />
<result name="fileUpload" type="richtexteditorFileUpload" />
</action>
</package>
<package name="richtexteditor-upload" extends="webwork-default"
namespace="/webwork/richtexteditor/editor/filemanager/upload">
<action name="uploader"
class="com.opensymphony.webwork.components.DefaultRichtexteditorConnector"
method="upload">
<result name="richtexteditorFileUpload" />
</action>
</package>
存在如下问题:
1.中文环境默认是繁体,需要去包里面用zh-cn.js替换zh.js
2.String path = "file://"+servletContext.getRealPath("/WEB-INF/classes"+actualServerPath),windows文件路径是\,webwork没有转义或者把\替换成/,对文件的访问都是通过new File(new URI(filePath))来访问,在我机子上会出例外
com.opensymphony.webwork.dispatcher.DispatcherUtils - Could not execute action
java.lang.IllegalArgumentException: URI has an authority component
at java.io.File.<init>(File.java:326)
at com.opensymphony.webwork.components.DefaultRichtexteditorConnector.makeDirIfNotExists(DefaultRichtexteditorConnector.java:171)
解决方法是自己写一个类继承com.opensymphony.webwork.components.DefaultRichtexteditorConnector然后覆盖它的方法
3.文件图片默认是保存在\WEB-INF\classes\com\opensymphony\webwork\static\richtexteditor\data里面,写入和读取都存在问题,写入的时候如果context是reloadable="true"则会引发context的reload,在context起来之后新加的文件比如test.jpg不能通过url来访问/webwork/data/test.jpg,这个应该是classloader不会在context启动之后加载这些文件
4.上传的表单里面没有action,虽然tag里面默认是
imageUploadURL="/webwork/richtexteditor/editor/filemanager/upload/uploader.action?Type=Image"
flashUploadURL="/webwork/richtexteditor/editor/filemanager/upload/uploader.action?Type=Flash"
linkUploadURL="/webwork/richtexteditor/editor/filemanager/upload/uploader.action?Type=File"
wikidocs里面说是"/webwork/static/richtexteditor/editor/filemanager/upload/uploader.action?Type=File"应该是多了个/static
但是实际上上传的form里面的action是空的,上传不了东西,这个可能需要去改fckeditor