整合一个编辑器,其实很简单。首先找到他的源码,以editor.md 为例:https://github.com/pandao/editor.md
下载后,到examples文件夹看看,看到一个simple.html的例子,这就是可以复制的前端代码:
到myeclipse中新建一个应用, 并添加spring支持(公司用jdk1.7,就简单用spring4.2.5, 不用spring boot,理解整合原理就行)
着重看下前端的页面:
- index.jsp,css和js自己拷贝并改下路径
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Simple example - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/editormd.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="layout">
<header>
<h1>Simple example</h1>
</header>
<form action="markdownTest" method="post">
<div id="test-editormd">
<textarea style="display:none;" name="markdownContent"></textarea>
</div>
<button type="submit" class="btn btn-info col-md-offset-3 col-md-6">添加</button>
</form>
</div>
<script