zoukankan      html  css  js  c++  java
  • 11月27日总结生成数据字典后端servlet层

    servlet层:

    package servlet;

    import dao.tabledao;
    import net.sf.json.JSONArray;
    import org.json.JSONObject;

    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 java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.SQLException;

    @WebServlet("/sqlServlet")
    public class sqlServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    String colname=(String)request.getSession().getAttribute("colname");
    PrintWriter out=response.getWriter();
    JSONObject jsonObject=new JSONObject();
    jsonObject.put("code",0);
    jsonObject.put("msg","");
    jsonObject.put("count",1);
    String sql="select * from col where table_name = '" + colname+"' ";
    System.out.println(sql);
    JSONArray result=null;
    try{
    tabledao he=new tabledao();
    result = JSONArray.fromObject(he.collist(sql));
    }catch(SQLException ex)
    {
    ex.printStackTrace();
    }
    jsonObject.put("data",result);
    System.out.println(jsonObject.toString());
    out.println(jsonObject.toString());
    out.flush();
    out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    this.doPost(request,response);

    }
    }
  • 相关阅读:
    CSP-J2019游记&解题报告
    旋转立方体实现
    博客背景线条实现
    垃圾基数排序
    链表实现队列(指针)
    公共子序列(luogu P1439)
    可并堆(左偏树)
    搜索(靶形数独)
    线段树(压位)luogu P1558色板游戏
    线段树区间取反
  • 原文地址:https://www.cnblogs.com/lkwkk/p/15613175.html
Copyright © 2011-2022 走看看