第三方外掛的引用(1) : SSM,springboot 引入ueditor及圖片上傳阿里雲OS和展示
阿新 • • 發佈:2019-01-09
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ueditor-demo</title> </head> <body> <form id="upload" method="post" action="/demo1" enctype="multipart/form-data" onclick="SetValue()"> <div> <!-- 這裡可設定寬度,下面js設定高度 --> <script id="editor" type="text/plain" style="width: 1000px;"></script> </div> <!-- 該隱藏文字域就是傳至後臺專用的 --> <textarea style="display: none;" id="infomationContent" name="content"></textarea> <br> <input type="submit" value="提交"> </form> </body> <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/ejs/jquery-1.11.3.min.js"></script> <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/ueditor/ueditor.config.js"> </script> <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/ueditor/ueditor.all.js"> </script> <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/ueditor/lang/zh-cn/zh-cn.js"></script> <script type="text/javascript"> var ue = UE.getEditor('editor'); //UE.getEditor('aaa', { initialFrameWidth: null }); $(document).ready(function() { var value = $("#infomationContent").val(); ue.addListener("ready", function() { // editor準備好之後才可以使用 ue.setContent(value); }); }); ue.ready(function() { ue.setHeight(400); //設定編輯器的內容 // ue.setContent('hello'); // //獲取html內容,返回: <p>hello</p> // var html = ue.getContent(); // //獲取純文字內容,返回: hello // var txt = ue.getContentTxt(); }); function SetValue() { var value = UE.getEditor('editor').getContent(); console.log(value); $("#infomationContent").val(value); }; </script> </html>