中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

jsp解決kindeditor在線編輯器struts圖片上傳問(wèn)題

2018-07-20    來(lái)源:編程學(xué)習(xí)網(wǎng)

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用

1、下載

    官網(wǎng)下載ckeditor,解壓后去掉不需要的部分,僅需保留plugin,lang,theme文件夾,這三個(gè)文件夾中用不到的東西可以刪除, 比如lang文件下存放所有語(yǔ)言文件js,僅僅  保留en.js和zh_CN.js即可,保留jsp文件夾下的json_upload.jsp文件和 kindeditor.js文件即可,把jsp下面的jar導(dǎo)入

  

1
<span style="font-family: 幼圓; font-size: 18pt;"><a >在線編輯器:http://kindeditor.net/</a></span>
 

 

2、修改json_upload.jsp

  修改json_upload.jsp文件保存路徑即可修改一下兩句即可。

  //文件保存目錄路徑
  String savePath = pageContext.getServletContext().getRealPath("/upload");

  //文件保存目錄URL,此處為絕對(duì)路徑
  String saveUrl  = request.getContextPath()+"/upload";

 3、可選

  obj.put("url", request.getContextPath()+"/img/" + newFileName);//修改返回到編輯器顯示的圖片

4、在plugins/images/image.js修改

          uploadJson = K.undef(self.uploadJson, self.basePath + 'jsp/upload_json.jsp')

5、在plugins/filemanager/filemanager.js修改

        fileManagerJson = K.undef(self.fileManagerJson, self.basePath + 'jsp/file_manager_json.jsp'),

6、jsp中

  <link rel="stylesheet" href="<%=application.getContextPath() %>/themes/default/default.css" />
    <script charset="utf-8" src="<%=application.getContextPath() %>/js/kindeditor.js"></script>
    <script charset="utf-8" src="<%=application.getContextPath() %>/lang/zh_CN.js"></script>

  <script charset="utf-8" src="<%=application.getContextPath() %>/lang/zh_CN.js"></script>
              <script>
            var editor;
            KindEditor.ready(function(K) {
                editor = K.create('textarea[id="content"]', {
                    filterMode:false,
                    resizeType : 1,
                    allowPreviewEmoticons : true,
                    allowImageUpload : true,
                    items : [
                        'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                        'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                        'insertunorderedlist', '|', 'emoticons', 'image', 'link']
                    
                    });
                K('input[name=submit]').click(function(e) {
                    editor.value=editor.text();
                });
            });
        </script>

       <textarea  tabindex="4"  name="brand.content" id="content" style="width:80.2%"></textarea>

----------------------------struts----------------------------------------------------

1、struts直接<url-pattern>/*</url-pattern>會(huì)攔截了在線編輯器的url,所以需要進(jìn)行下面的配置,這個(gè)只是解決那個(gè)問(wèn)題的其中一種

2、自定義filter

public class KindeditorUrlFilter extends StrutsPrepareAndExecuteFilter {

    @Override
    public void doFilter(ServletRequest req, ServletResponse res,
            FilterChain chain) throws IOException, ServletException {
        
        HttpServletRequest request = (HttpServletRequest) req;    
           //不過(guò)濾的url    
           String url = request.getServletPath();  
           
           if ("/js/jsp/file_manager_json.jsp".equals(url)) {     
                
               chain.doFilter(req, res);    
           }else if("/js/jsp/upload_json.jsp".equals(url)){  
               chain.doFilter(req, res);  
           }else{    
               //System.out.println("使用默認(rèn)的過(guò)濾器");    
               super.doFilter(req, res, chain);    
           }    
    }
}

3、web.xml配置filter

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>com.dan.action.KindeditorUrlFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:關(guān)于 Swift 的一點(diǎn)初步看法

下一篇:Java I/O底層是如何工作的?