Springboot+thymeleaf統合ueditor


環境
springboot1.5.8 、ueditor 1.4.3、thymeleaf
jspバージョンueditorをダウンロード
ueditorバックグラウンドのソースコードをsrc/mian/javaディレクトリにコピーし、ファイルConfigManagerを変更
private void initEnv () throws FileNotFoundException, IOException {
      
      File file = new File( this.originalPath );
      
      if ( !file.isAbsolute() ) {

         file = new File( file.getAbsolutePath() );
         file = new File(file.getCanonicalPath());
      }
      
      this.parentPath = file.getParent();

      /**
         *     config    
         * */
        ClassPathResource resource = new ClassPathResource(configFileName);
        file = resource.getFile();
        BufferedReader br = new BufferedReader(new FileReader(file));
        StringBuilder stringBuilder = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null){
            stringBuilder.append(line);
        }
//        String configContent = this.readFile( this.getConfigPath() );//     
        String configContent = stringBuilder.toString();
        try{
         JSONObject jsonConfig = new JSONObject( configContent );
         this.jsonConfig = jsonConfig;
      } catch ( Exception e ) {
         this.jsonConfig = null;
      }
      
   }

フロントエンドは変更ファイルueditorを呼び出します.config.js
var URL = rootPath + "js/ueditor/";

/**
 *      。  ,               URL  。
 */
window.UEDITOR_CONFIG = {

    //            ,       
    UEDITOR_HOME_URL: URL

    //            
    , serverUrl: rootPath + "/comm/ueditor"

config.jsonはresoucesフォルダにコピー
バックグラウンドコントローラに対応するエントリメソッドを追加
//ueditr    
    @ResponseBody
    @RequestMapping(value = "/ueditor")
    public void ueditor(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.setCharacterEncoding( "utf-8" );
        response.setHeader("Content-Type" , "text/html");
        String realPath = request.getSession().getServletContext().getRealPath("/");
        PrintWriter out = response.getWriter();
        String exec = new ActionEnter(request, realPath).exec();

        logger.info("ueditor    "+exec);

        out.flush();
        out.write(exec);
    }