無聊人士

          搬家==》www.soapui.cn

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            32 隨筆 :: 0 文章 :: 60 評論 :: 0 Trackbacks

          感謝google,感謝"webwork2.2.2的富文本編輯器的不完美解決方法"一文,感謝李李。當然,最應該感謝的是開源(刨源代碼刨出來的)。

          1、解決/webwork/*的路徑問題
          解決辦法見“http://www.aygfsteel.com/mmwy/archive/2006/08/18/64234.html
          BTW:也可以象“不完美解決方法”一文中描述的一樣,設webwork.serve.static=false,將static/下的東西拷至/webwork目錄下。

          2、重寫(繼承)DefaultRichtexteditorConnector類,解決無法在windows平臺上創建目錄的問題

          ?1 public ? class ?RichtexteditorConnector? extends ?DefaultRichtexteditorConnector? {
          ?2 ?? /**
          ?3 ???*?解決無法在windows平臺上創建目錄的問題
          ?4 ???*?overriding?methods
          ?5 ???*?(non-Javadoc)
          ?6 ???*? @see ?com.opensymphony.webwork.components.DefaultRichtexteditorConnector#calculateActualServerPath(java.lang.String,?java.lang.String,?java.lang.String)
          ?7 ??? */

          ?8 ?? protected ?String?calculateActualServerPath(String?actualServerPath,
          ?9 ??????String?type,?String?folderPath)? throws ?Exception? {
          10 ????String?path? = ?StringUtils.replaceChars( " file:/// "
          11 ???????? + ?servletContext.getRealPath( " / " ? + ?actualServerPath),? ' \\ ' ,? ' / ' );
          12 ????makeDirIfNotExists(path);
          13 ????path? = ?path.endsWith( " / " )
          14 ?????? ? ?path
          15 ??????:?path? + ? " / " ;
          16 ???? return ?path? + ?type? + ?folderPath;
          17 ??}

          18
          19 ?? private ?ServletContext?servletContext;
          20
          21 ?? public ? void ?setServletContext(ServletContext?servletContext)? {
          22 ???? this .servletContext? = ?servletContext;
          23 ??}

          24 }

          3、配置webwork.xml,解決上傳路徑自定義問題(actualServerPath參數,默認的使用DefaultRichtexteditorConnector類中protected String _actualServerPath = "/com/opensymphony/webwork/static/richtexteditor/data/";的定義),解決獲取上傳文件url路徑問題(默認的使用AbstractRichtexteditorConnector類中String _serverPath = "/webwork/richtexteditor/data/";的定義)

          ?1 ???? < package
          ?2 ???????? name ="richtexteditor-browse"
          ?3 ????????extends ="webwork-default"
          ?4 ????????namespace ="/webwork/richtexteditor/editor/filemanager/browser/default/connectors/jsp" >
          ?5 ???????? < action
          ?6 ???????????? name ="connector"
          ?7 ????????????class ="com.mmwy.weblogic_sitemesh.util.RichtexteditorConnector"
          ?8 ????????????method ="browse" >
          ?9 ???????????? < result
          10 ???????????????? name ="getFolders"
          11 ????????????????type ="richtexteditorGetFolders" ? />
          12 ???????????? < result
          13 ???????????????? name ="getFoldersAndFiles"
          14 ????????????????type ="richtexteditorGetFoldersAndFiles" ? />
          15 ???????????? < result
          16 ???????????????? name ="createFolder"
          17 ????????????????type ="richtexteditorCreateFolder" ? />
          18 ???????????? < result
          19 ???????????????? name ="fileUpload"
          20 ????????????????type ="richtexteditorFileUpload" ? />
          21 ???????????? < param? name ="actualServerPath" > /upload/ </ param >
          22 ???????????? < param? name ="serverPath" > /upload/ </ param >
          23 ???????? </ action >
          24 ???? </ package >
          25
          26 ???? < package
          27 ???????? name ="richtexteditor-upload"
          28 ????????extends ="webwork-default"
          29 ????????namespace ="/webwork/richtexteditor/editor/filemanager/upload" >
          30 ???????? < action
          31 ???????????? name ="uploader"
          32 ????????????class ="com.mmwy.weblogic_sitemesh.util.RichtexteditorConnector"
          33 ????????????method ="upload" >
          34 ???????????? < result? name ="richtexteditorFileUpload" ? />
          35 ???????????? < param? name ="actualServerPath" > /upload/ </ param >
          36 ???????????? < param? name ="serverPath" > /upload/ </ param >
          37 ???????? </ action >
          38 ???? </ package >

          注意:serverPath路徑必須有后面的"/"。

          4、解決獲取上傳文件url只能使用80端口的問題
          順著源碼一直跟進,首先是DefaultRichtexteditorConnector類:

          1 ???? protected ?String?calculateServerPath(String?serverPath,?String?folderPath,?String?type)? throws ?Exception? {
          2 ???????? // return?UrlHelper.buildUrl(serverPath,?_request,?_response,?null,?_request.getScheme(),?true,?true,?true);
          3 ???????? return ?UrlHelper.buildUrl(serverPath + type + folderPath,?_request,?_response,? new ?HashMap(),?_request.getScheme(),? true ,? true ,? true );
          4 ????}

          再跟進UrlHelper.buildUrl方法

          ?1 ???? public ? static ?String?buildUrl(String?action,?HttpServletRequest?request,?HttpServletResponse?response,?Map?params,?String?scheme,? boolean ?includeContext,? boolean ?encodeResult,? boolean ?forceAddSchemeHostAndPort)? {
          ?2 ????????StringBuffer?link? = ? new ?StringBuffer();
          ?3
          ?4 ???????? boolean ?changedScheme? = ? false ;
          ?5
          ?6 ???????? int ?httpPort? = ?DEFAULT_HTTP_PORT;
          ?7
          ?8 ???????? try ? {
          ?9 ????????????httpPort? = ?Integer.parseInt((String)?Configuration.get(WebWorkConstants.WEBWORK_URL_HTTP_PORT));
          10 ????????}
          ? catch ?(Exception?ex)? {
          11 ????????}

          12
          13 ???????? int ?httpsPort? = ?DEFAULT_HTTPS_PORT;
          14
          15 ???????? try ? {
          16 ????????????httpsPort? = ?Integer.parseInt((String)?Configuration.get(WebWorkConstants.WEBWORK_URL_HTTPS_PORT));
          17 ????????}
          ? catch ?(Exception?ex)? {
          18 ????????}

          19

          因此,解決這個問題的方法很簡單,只要在webwork.properties中設webwork.url.http.port = 8080即可。

          5、語言問題
          RichTextEditor標記autoDetectLanguage默認值為true,在中文環境下使用/editor/lang/zh.js,顯示繁體中文字符,而簡體中文應該使用zh-cn.js,因此,應設置defaultLanguage="zh-cn"。

          1 ???????????? < @ww .richtexteditor
          2 ????????????????theme ="simple"
          3 ????????????????defaultLanguage ="zh-cn"
          4 ????????????????width ="750"
          5 ????????????????height ="500"
          6 ????????????????name ="description4" ? />

          ?



          ?

          posted on 2006-09-11 12:29 mmwy 閱讀(2277) 評論(0)  編輯  收藏 所屬分類: WebWork、Struts2、FreeMarker
          主站蜘蛛池模板: 治县。| 报价| 稷山县| 房山区| 湘乡市| 潼关县| 德阳市| 合川市| 茂名市| 横峰县| 宁安市| 平湖市| 出国| 陕西省| 南宁市| 新乐市| 广宁县| 克拉玛依市| 梨树县| 垫江县| 酒泉市| 昔阳县| 登封市| 清水县| 松桃| 方山县| 长岛县| 霍山县| 宜州市| 青川县| 绥阳县| 黄大仙区| 阿尔山市| 富宁县| 三穗县| 江安县| 五河县| 繁峙县| 东乡族自治县| 万全县| 石嘴山市|