继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

struts2+Easyui 实现html文本框

OneStuent
关注TA
已关注
手记 10
粉丝 15
获赞 61

先贴出代码

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="UTF-8"%>
<%@ page import="javax.servlet.http.HttpSession"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    Integer userType = 0;
%>
               <--引入Easyui,kindeditor 的js文件-->
        <script src="js/jquery.min.js"></script>
        <script src="js/jquery.easyui.min.js"></script>
        <script src="js/easyui-lang-zh_CN.js"></script>
        <link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="themes/icon.css">

            <link rel="stylesheet" href="js/kindeditor-4.1.10/themes/default/default.css">
            <script charset="utf-8" src="js/kindeditor-4.1.10/kindeditor-min.js"></script>
            <script charset="utf-8" src="js/kindeditor-4.1.10/lang/zh_CN.js"></script>
<head>
    <body>
            <!-- form表单 -->
            <form action="/fileSaveAction" method="post">
                <input type="submit" value="提交" onclick="save()"/>
<-- 文本框-->
                <textarea id="saveId" name="content" style="width:800px;height:200px;border: 0 none;visibility:hidden;" charset="utf-8"></textarea>
            </form>
            <script language="JavaScript" type="text/javascript">
                var editor;
                KindEditor.ready(function(K) {
                    editor = K.create('textarea[name="content"]', {          
                            resizeType : 1,
                            allowPreviewEmoticons : false,
                            items : [    'source', '', 'undo','redo','','formatblock','fontname', 'fontsize', '', 
                                        'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                                        'strikethrough','removeformat', '', 'justifyleft', 'justifycenter', 
                                        'justifyright', 'insertorderedlist','insertunorderedlist','insertorderedlist',
                                        'insertunorderedlist', '', 'emoticons', 'image', 'link','table','hr','preview'],
                    });
                    //清空KindEditor, 0表示第一个KindEditor编辑器对象
                    KindEditor.instances[0].html("");
                });
                function save(){
                    //获取文本框的值
                    editor.sync();
                    var html = document.getElementById('saveId').value;
                    alert(html);
                    document.forms[0].action="fileSaveAction.action?html="+html;
                    document.forms[0].submit;

                }
            </script>

    </body>
</html>
打开App,阅读手记
8人推荐
发表评论
随时随地看视频慕课网APP