<!--導入在線HTML編輯器 --> <script type="text/javascript" src="../../editor/kindeditor.js" ></script> <script type="text/javascript" src="../../editor/lang/zh_CN.js" ></script> <link rel="stylesheet" href="../../editor/themes/default/default.css" />
KindEditor 默認採用 PHP 實現,若是使用 java 實現,須要設置初始化參數 javascript
設置頁面 kindeditor 請求路徑 php
三、 編寫 PromotionAction 添加 save 方法css
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>添加宣傳任務</title> <!-- 導入jquery核心類庫 --> <script type="text/javascript" src="../../js/jquery-1.8.3.js"></script> <!-- 導入easyui類庫 --> <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="../../css/default.css"> <script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script> <script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script> <!--導入在線HTML編輯器 --> <script type="text/javascript" src="../../editor/kindeditor.js" ></script> <script type="text/javascript" src="../../editor/lang/zh_CN.js" ></script> <link rel="stylesheet" href="../../editor/themes/default/default.css" /> <script type="text/javascript"> $(function(){ $("body").css({visibility:"visible"}); $("#back").click(function(){ location.href = "promotion.html"; }); KindEditor.ready(function(K) { window.editor = K.create('#description',{ items : [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about' ], allowFileManager:true, uploadJson : '../../image_upload.action', fileManagerJson : '../../image_manage.action' }); }); // 爲保存按鈕,添加click事件 $("#save").click(function(){ if($("#promotionForm").form('validate')){ // 經過kindEditor數據到textarea window.editor.sync(); // 提交表單 $("#promotionForm").submit(); }else{ // 校驗失敗 $.messager.alert("警告信息","表單中存在數據非法項!","warning"); } }); }); </script> </head> <body class="easyui-layout" style="visibility:hidden;"> <div region="north" style="height:31px;overflow:hidden;" split="false" border="false"> <div class="datagrid-toolbar"> <a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">保存</a> <a id="back" icon="icon-back" href="#" class="easyui-linkbutton" plain="true">返回列表</a> </div> </div> <div region="center" style="overflow:auto;padding:5px;" border="false"> <form id="promotionForm" enctype="multipart/form-data" action="../../promotion_save.action" method="post"> <table class="table-edit" width="95%" align="center"> <tr class="title"> <td colspan="4">宣傳任務</td> </tr> <tr> <td>宣傳概要(標題):</td> <td colspan="3"> <input type="text" name="title" id="title" class="easyui-validatebox" required="true" /> </td> </tr> <tr> <td>活動範圍:</td> <td> <input type="text" name="activeScope" id="activeScope" class="easyui-validatebox" /> </td> <td>宣傳圖片:</td> <td> <input type="file" name="titleImgFile" id="titleImg" class="easyui-validatebox" required="true"/> </td> </tr> <tr> <td>發佈時間: </td> <td> <input type="text" name="startDate" id="startDate" class="easyui-datebox" required="true" /> </td> <td>失效時間: </td> <td> <input type="text" name="endDate" id="endDate" class="easyui-datebox" required="true" /> </td> </tr> <tr> <td>宣傳內容(活動描述信息):</td> <td colspan="3"> <textarea id="description" name="description" style="width:80%" rows="20"></textarea> </td> </tr> </table> </form> </div> </body> </html>
package cn.itcast.bos.domain.take_delivery; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import javax.xml.bind.annotation.XmlRootElement; import cn.itcast.bos.constant.Constants; /** * @description:促銷信息實體類 */ @Entity @Table(name = "T_PROMOTION") @XmlRootElement(name = "promotion") public class Promotion implements Serializable { @Id @GeneratedValue @Column(name = "C_ID") private Integer id; @Column(name = "C_TITLE") private String title; // 宣傳概要(標題) @Column(name = "C_TITLE_IMG") private String titleImg; // 宣傳圖片 @Column(name = "C_ACTIVE_SCOPE") private String activeScope;// 活動範圍 @Column(name = "C_START_DATE") private Date startDate; // 發佈時間 @Column(name = "C_END_DATE") private Date endDate; // 失效時間 @Column(name = "C_UPDATE_TIME") private Date updateTime; // 更新時間 @Column(name = "C_UPDATE_UNIT") private String updateUnit; // 更新單位 @Column(name = "C_UPDATE_USER") private String updateUser;// 更新人 後續與後臺用戶關聯 @Column(name = "C_STATUS") private String status = "1"; // 狀態 可取值:1.進行中 2. 已結束 @Column(name = "C_DESCRIPTION") private String description; // 宣傳內容(活動描述信息) public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getTitleImg() { if (titleImg.startsWith(Constants.BOS_MANAGEMENT_HOST)) { return titleImg; } return Constants.BOS_MANAGEMENT_HOST + titleImg; } public void setTitleImg(String titleImg) { this.titleImg = titleImg; } public String getActiveScope() { return activeScope; } public void setActiveScope(String activeScope) { this.activeScope = activeScope; } public Date getStartDate() { return startDate; } public void setStartDate(Date startDate) { this.startDate = startDate; } public Date getEndDate() { return endDate; } public void setEndDate(Date endDate) { this.endDate = endDate; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public String getUpdateUnit() { return updateUnit; } public void setUpdateUnit(String updateUnit) { this.updateUnit = updateUnit; } public String getUpdateUser() { return updateUser; } public void setUpdateUser(String updateUser) { this.updateUser = updateUser; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getDescription() { if (description.contains("<img src=\"" + Constants.BOS_MANAGEMENT_HOST + "/")) { return description; } return description.replace("<img src=\"/", "<img src=\"" + Constants.BOS_MANAGEMENT_HOST + "/"); } public void setDescription(String description) { this.description = description; } }