Parameters in GetParameter () in Java (personal notes) __java

Source: Internet
Author: User


The arguments in the GetParameter () function are passed from the page, such as edit.jsp userid:

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%> <% String Path = Request.getcontextpath ()
;
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; %> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" > 
below is the control layer:

Package Com.demo.controller;

Import java.io.IOException;
Import javax.servlet.ServletException;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;

Import Javax.servlet.http.HttpServletResponse;
Import Com.demo.dao.UserDao;

Import Com.demo.entity.User; public class Updatecontroller extends HttpServlet {protected void doget (HttpServletRequest req, httpservletrespons
   E resp) throws Servletexception, IOException {doPost (req, resp);
      } protected void DoPost (HttpServletRequest req, HttpServletResponse resp) throws Servletexception, IOException {
      String ids = Req.getparameter ("UserId"). Trim ();
      Long id = (long) 0;
      if (IDs!= null) {id = long.parselong (IDS);
      String name = Req.getparameter ("name"). Trim ();
      String Password = req.getparameter ("password"). Trim ();
      User user = new user ();
      User.setid (ID);
      User.setname (name);
      User.setpassword (password); Userdao Userdao= new Userdao ();
      Userdao.updateuser (user);
   Resp.sendredirect ("list.do"); }
}
which
String ids = Req.getparameter ("UserId"). Trim () is the value of the UserId in the page note: the trim () method is to remove the space before and after

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.