zoukankan      html  css  js  c++  java
  • 1月13日 家庭小账本(改) 开发记录

    1、阅读构建之法 现代软件工程(第三版)

    2、观看JSP+Servlet+MySql+Tomcat+JDBC项目详细讲解

    3、更新信息代码修改如下

    package com.edu.servlet;

    import java.io.IOException;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;

    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.edu.dao.Userdao;
    import com.edu.entity.User;

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

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    String ids = request.getParameter("id");
    int id = Integer.parseInt(ids);
    String username = request.getParameter("username");
    String userused = request.getParameter("userused");
    String usermoney = request.getParameter("usermoney");
    String usedate = request.getParameter("usedate");
    String used = request.getParameter("used");
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
    date=sdf.parse(usedate);
    } catch (ParseException e) {
    // TODO 自动生成的 catc
    e.printStackTrace();
    }
    java.sql.Date sDate = new java.sql.Date(date.getTime());
    User user = new User(id,username,userused,usermoney,sDate,used);
    Userdao dao = new Userdao();
    if(dao.UpdateId(user))
    {
    System.out.println("修改成功!!!");
    }
    else {
    System.out.println("修改失败!!!");
    }
    request.getRequestDispatcher("/Showall.jsp").forward(request, response);
    }

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

    }

    package com.edu.servlet;

    import java.io.IOException;
    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.edu.dao.Userdao;
    import com.edu.entity.User;

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

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    Userdao dao = new Userdao();
    User user = new User();
    String ids = request.getParameter("id");
    int id = Integer.parseInt(ids);
    user = dao.ResearchId(id);
    request.setAttribute("user", user);
    /*if(dao.UpdateId(user))
    {
    System.out.println("修改成功!!!");
    }
    else {
    System.out.println("修改失败!!!");
    }*/
    request.getRequestDispatcher("/Updateused.jsp").forward(request, response);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

  • 相关阅读:
    文摘
    Maximal Square leetcode
    Majority Element II
    Merge k Sorted Lists leetcode
    学习方法-暗时间
    4sum leetcode
    valid parentheses
    两道考研算法设计题- 2010 2013
    regular expression matching DP
    valid sudoku leetcode
  • 原文地址:https://www.cnblogs.com/lx06/p/14415865.html
Copyright © 2011-2022 走看看