用户修改自己信息
public class UpdateUser extends HttpServlet {
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String realname = request.getParameter("realname");
String address = request.getParameter("address");
String money = request.getParameter("money");
DataBaseHelper d = new DataBaseHelper();
HttpSession session = request.getSession();
int id =Integer.parseInt((String)session.getAttribute("id"));
System.out.println("update userinfo SET realname ="+realname+",address ="+address+",money = "+money+" WHERE id="+id);
d.update("update userinfo SET realname ='"+realname+"',address ='"+address+"',money = '"+money+"' WHERE id="+id);
d.close();
response.sendRedirect("myshop.jsp");
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
}