Update_User.java
上传用户:huaxinghn
上传日期:2022-04-20
资源大小:673k
文件大小:1k
- package lilin.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.sql.SQLException;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import lilin.bean.User;
- import lilin.dao.DB;
- public class Update_User extends HttpServlet {
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- this.doPost(request, response);
- }
-
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- request.setCharacterEncoding("utf-8");
- response.setContentType("text/html;charset=utf-8");
- PrintWriter out = response.getWriter();
-
- User u = new User();
- DB db_ref = null;
- String id = request.getParameter("id");
- String value = request.getParameter("name");
- String type = request.getParameter("type");
-
-
- try {
- db_ref = new DB();
- boolean is_true = db_ref.update_User(Integer.parseInt(id),type,value);
-
- if(is_true){
- out.println(1);
- }else{
- out.println(0);
- }
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }finally{
- db_ref.closeAll();
- }
- out.flush();
- out.close();
- }
- }