• 6月15日


    昨天偷了懒

    今天发布剩余的servlet

    package servlet;

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.SQLException;
    import java.util.List;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import com.fasterxml.jackson.databind.ObjectMapper;

    import bean.paper;
    import dao.dao;

    /**
    * Servlet implementation class getallpaper
    */
    @WebServlet("/getallpaper")
    public class getallpaper extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public getallpaper() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");
    dao p=new dao();
    PrintWriter out=response.getWriter();
    String json="{}";
    try {
    List<paper> list=p.getallpaper();
    ObjectMapper om=new ObjectMapper(); //需要导包jackson
    json=om.writeValueAsString(list);
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    out.println(json);
    out.flush();
    out.close();
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

    package servlet;

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.SQLException;
    import java.util.List;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import com.fasterxml.jackson.databind.ObjectMapper;

    import bean.keyword;
    import bean.paper;
    import dao.dao;

    /**
    * Servlet implementation class wordcloud
    */
    @WebServlet("/wordcloud")
    public class wordcloud extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public wordcloud() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");
    dao p=new dao();
    String id=request.getParameter("id");
    String name=request.getParameter("name");
    String writer=request.getParameter("writer");
    String time=request.getParameter("time");
    String keywords=request.getParameter("keywords");

    PrintWriter out=response.getWriter();
    String json="{}";
    try {
    List<keyword> list=p.getkey(id,name,writer,time,keywords);
    ObjectMapper om=new ObjectMapper();
    json=om.writeValueAsString(list);
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    out.println(json);
    out.flush();
    out.close();
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

  • 相关阅读:
    逻辑回归&线性支持向量机
    回归算法比较【线性回归,Ridge回归,Lasso回归】
    K邻近回归算法
    matplotlib正弦和余弦图
    matplotlib箱线图与柱状图比较
    查看neighbors大小对K近邻分类算法预测准确度和泛化能力的影响
    K邻近分类算法
    软件设计师考试18年上半年上午考试真题及解析(一)
    Solr高级搜索【自动建议】
    Solr高级搜索【拼写检查】
  • 原文地址:https://www.cnblogs.com/ldy2396/p/14912090.html
Copyright © 2020-2023  润新知