zoukankan      html  css  js  c++  java
  • JAVA Web request对象

     request对象 

    request对象用于处理HTTP中请求的各项参数,最常用的就是获取请求参数。如果要同时指定多个参数,各参数间使用与(&)符合分隔即可

    例通过request对象的getParameter()方法获取传递的参数值代码如下

    //index页面用于连接到delta

    <%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
    <title>使用request对象获取请求参数值</title>
    </head>
    <body>
    <a href="deal.jsp?id=1&user=">处理页</a>

    <--此处的为id指定参数名和值,为user指定字参数名没有指定参数值-->
    </body>
    </html>

    注意:request的getParameter方法获取传递的参数时,如果指定的参数不存在,将返回null,指定了参数名但未指定参数,将返回空的字符串""

    //delete页面

    <%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="utf-8"%>
    <%


    String id=request.getParameter("id"); //获取id参数的值
    String user=request.getParameter("user");//获取user参数的值
    String pwd=request.getParameter("pwd");//获取pwd参数值
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>处理页</title>
    </head>
    <body>
    id参数的值为:<%=id %><br>
    user参数的值为:<%=user %><br>
    pwd参数的值为:<%=pwd %>
    </body>
    </html>

    既然走上了这条路,那么久不能背信弃义,就要一直走下去。即使前面是刀山火海也要闯一闯。至于结果是悲喜,或许只有时间才能给出答案。
  • 相关阅读:
    The Fifth Season Gym
    SuperHyperMarket Gym
    Far Manager Gym
    Game Map------Gym
    Happy Number
    Pursuing the Happiness
    Digit sum-----The Preliminary Contest for ICPC Asia Shanghai 2019
    Light bulbs------The Preliminary Contest for ICPC Asia Shanghai 2019
    P2921 [USACO08DEC]在农场万圣节Trick or Treat on the Farm
    HDU 1203 I NEED A OFFER!
  • 原文地址:https://www.cnblogs.com/yckv/p/4808978.html
Copyright © 2011-2022 走看看