Markdown编辑器

第一步:下载插件

项目地址:http://pandao.github.io/editor.md/

第二步:解压插件,并将需要的包拷进项目。

Markdown编辑器_第1张图片
image

index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

  
    $Title$
  
  
新增主题
编辑主题
  


add_or_edit.jsp

<%--
  Created by IntelliJ IDEA.
  User: ttc
  Date: 2018/3/18
  Time: 12:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    $Title$
    
    
    
    


SaveTopicServlet .java

@WebServlet(name = "SaveTopicServlet",urlPatterns = "/save_topic")
public class SaveTopicServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       String strHtml = request.getParameter("test-editormd-html-code");
        String strMarkdown = request.getParameter("topic_markdown_content");
        System.out.println(strHtml);
        System.out.println(strMarkdown);
        response.getWriter().print("ok");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}

EditServlet.java

@WebServlet(name = "EditServlet",urlPatterns = "/edit_topic")
public class EditServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String strMarkdown = "### fdsfd";
        request.setAttribute("topic_markdown_content",strMarkdown);
        request.getRequestDispatcher("add_or_edit.jsp").forward(request,response);
    }
}

你可能感兴趣的:(Markdown编辑器)