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);

    }
    }
  • 相关阅读:
    ionic 刷新页面的几种方法
    Highcharts中如何外部修改pointStart
    前端分页 思路
    快捷选时间
    获取今天,昨天,本周,上周,本月,上月时间
    angularjs 弹出框 $modal
    SQL 查找存在某内容的存储过程都有哪些
    LINQ to SQL和Entity Framework
    SQL模糊查询条件的四种匹配模式
    数据库--中文表名及字段名的优缺点
  • 原文地址:https://www.cnblogs.com/lkwkk/p/15613175.html
Copyright © 2011-2022 走看看