Search in sources :

Example 1 with InfoDao

use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.

the class InfoServlet method selectInfo.

public void selectInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InfoDao infodao = new InfoDao();
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int id = user.getUid();
    List infoList = infodao.queryInfo(id);
    // request.setAttribute("infoList", infoList);
    JsonArray array = new JsonArray();
    for (int i = 0; i < infoList.size(); i++) {
        Info single = (Info) infoList.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("date", single.getDate());
        ob.addProperty("read", "<a href=\"InfoServlet?action=single&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
        ob.addProperty("read1", "<a href=\"InfoServlet?action=singlepot&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
        ob.addProperty("del", "<a href=\"InfoServlet?action=delete&id=" + single.getId() + "\">删除记录</a>");
        array.add(ob);
    }
    PrintWriter out = response.getWriter();
    out.print(array);
    System.out.println(array);
// RequestDispatcher rd = request.getRequestDispatcher("infolist.jsp");
// request.setAttribute("listjson", array);
// rd.forward(request, response);
}
Also used : JsonArray(com.google.gson.JsonArray) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) JsonObject(com.google.gson.JsonObject) List(java.util.List) Info(com.zyf.bean.Info) PrintWriter(java.io.PrintWriter)

Example 2 with InfoDao

use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.

the class InfoServlet method tendInfo.

public void tendInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InfoDao infodao = new InfoDao();
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int id = user.getUid();
    List infoList = infodao.queryInfo(id);
    request.setAttribute("infoList", infoList);
    RequestDispatcher rd = request.getRequestDispatcher("infotend.jsp");
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) List(java.util.List) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 3 with InfoDao

use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.

the class InfoServlet method singlepotInfo.

public void singlepotInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InfoDao infodao = new InfoDao();
    int id = MyTools.strToint(request.getParameter("id"));
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    Info infosingle = infodao.queryInfoSingle(id, uid);
    request.setAttribute("infosingle", infosingle);
    RequestDispatcher rd = request.getRequestDispatcher("infosinglepot.jsp");
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) Info(com.zyf.bean.Info) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 4 with InfoDao

use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.

the class RelaServlet method selectInfo.

public void selectInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InfoDao infodao = new InfoDao();
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    int reid = MyTools.strToint(request.getParameter("para"));
    List relainfolist = infodao.queryRelaInfo(uid, reid);
    // request.setAttribute("relainfolist", relainfolist);
    JsonArray array = new JsonArray();
    for (int i = 0; i < relainfolist.size(); i++) {
        Info single = (Info) relainfolist.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("date", single.getDate());
        ob.addProperty("read", "<a href=\"RelaServlet?action=RelaInfoSingle&para=" + single.getId() + "&para1=" + reid + " \"target=\"_blank\">查看记录</a>");
        array.add(ob);
    }
    PrintWriter out = response.getWriter();
    out.print(array);
    System.out.println(array);
}
Also used : JsonArray(com.google.gson.JsonArray) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) JsonObject(com.google.gson.JsonObject) List(java.util.List) Info(com.zyf.bean.Info) PrintWriter(java.io.PrintWriter)

Example 5 with InfoDao

use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.

the class RelaServlet method relaTend.

private void relaTend(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InfoDao infodao = new InfoDao();
    int reid = MyTools.strToint(request.getParameter("para"));
    String relaname = request.getParameter("para1");
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    List infoRelaList = infodao.queryRelaInfo(uid, reid);
    request.setAttribute("infoRelaList", infoRelaList);
    request.setAttribute("relaname", relaname);
    String relaid = "";
    relaid = String.valueOf(reid);
    // 一个小细节,如果直接将int型传过去会报错
    request.setAttribute("reid", relaid);
    RequestDispatcher rd = request.getRequestDispatcher("relainfo.jsp");
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) List(java.util.List) RequestDispatcher(javax.servlet.RequestDispatcher)

Aggregations

InfoDao (com.zyf.dao.InfoDao)10 User (com.zyf.bean.User)9 HttpSession (javax.servlet.http.HttpSession)9 Info (com.zyf.bean.Info)8 List (java.util.List)6 RequestDispatcher (javax.servlet.RequestDispatcher)6 JsonArray (com.google.gson.JsonArray)4 JsonObject (com.google.gson.JsonObject)4 PrintWriter (java.io.PrintWriter)4