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

    }
    }
  • 相关阅读:
    MSSQLSERVER数据库 C#里调用存储过程,多参数查询,个人记录
    ASP.NET GridView和Repeater合并单元格
    C# XPath教程
    MSSQLSERVER数据库 导入文本文件
    MSSQLSERVER数据库 递归查询例子
    C# TreeView右键弹出菜单
    tomcat 下War包部署方法
    JAVA自定义标签教程及实例代码
    JAVA tag学习
    Java Quartz 自动调度
  • 原文地址:https://www.cnblogs.com/lkwkk/p/15613175.html
Copyright © 2011-2022 走看看