zoukankan      html  css  js  c++  java
  • vertx 获取请求参数

        表单登录(GET)

    1.  
      <form action="/login">
    2.  
      <input type="text" name="username"/>
    3.  
      <input type="password" name="password"/>
    4.  
      <input type="submit" />
    5.  
      </form>

    使用下面的代码,获取请求的参数没问题:

    1.  
      public class LoginHandler implements Handler<RoutingContext> {
    2.  
       
    3.  
      public void handle(RoutingContext rc) {
    4.  
       
    5.  
      String username = rc.request().getParam("username");
    6.  
      String password = rc.request().getParam("password");
    7.  
       
    8.  
      System.out.println(username + "-->" + password);
    9.  
       
    10.  
      rc.next();
    11.  
      }
    12.  
      }

     但是换成POST就得不到了,如果处理POST,需要用下面的方式处理

    1.  
      public class LoginHandler implements Handler<RoutingContext> {
    2.  
       
    3.  
      public void handle(RoutingContext rc) {
    4.  
       
    5.  
      rc.request().setExpectMultipart(true);
    6.  
      rc.request().endHandler(end -> {
    7.  
       
    8.  
      String username = rc.request().formAttributes().get("username");
    9.  
      String password = rc.request().formAttributes().get("password");
    10.  
       
    11.  
      System.out.println(username + "-->" + password);
    12.  
       
    13.  
      rc.next();
    14.  
      });
    15.  
      }
    16.  
      }
     
     
  • 相关阅读:
    cookie操作和代理
    发起post请求
    scrapy核心组件
    爬取多个url页面数据--手动实现
    scrapy之持久化存储
    selenium + phantomJs
    scrapy框架简介和基础使用
    校验验证码 实现登录验证
    beautifulsoup解析
    xpath
  • 原文地址:https://www.cnblogs.com/exmyth/p/14207271.html
Copyright © 2011-2022 走看看