request方法总结
1.获得指定的头
- String header = response.getHeader("user-agent");
2.获得所有头的名称
- Enumeration<String> headerNames = request.getHeaderNames();
- while (headerNames.hasMoreElements()) {// 判断是否还有下一个元素
- String nextElement = headerNames.nextElement();// 获取headerNames集合中的请求头
- String header2 = request.getHeader(nextElement);// 通过请求头得到请求内容
- System.out.println(nextElement + ":" + header2);
- }
3.获取请求方式
- String method = request.getMethod();
4.获得请求的资源
- String requestURI = request.getRequestURI();
- StringBuffer requestURL = request.getRequestURL();
5.获取web应用的地址名称
- String contextPath = request.getContextPath();
6.获取地址后的参数字符串
- String queryString = request.getQueryString();
7.获取客户端信息--获得IP地址
- String remoteAddr = request.getRemoteAddr();
8.获取单个表单中的value值
- String usernam = request.getParameter("usernam");
9.获取多个表单的value值
- String[] parameterValues = request.getParameterValues("hobby");
- System.out.print("hobby.values:");
- for (String string : parameterValues) {
- System.err.print(string + " ");
- }
10.获得所有参数的name
- Enumeration<String> parameterNames = request.getParameterNames();
- for (String string2 : parameterValues) {
- System.out.println(parameterNames.nextElement());
- }
11.将获得的所有参数封装到一个Map<String,String[]>中
- Map<String, String[]> parameterMap = request.getParameterMap();
- for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
- System.out.println(entry.getKey());
- for (String string : entry.getValue()) {
- System.out.println(string);
- }
- System.out.println("----------------");
- }
12.跳转方式
- 1.转发:地址不变
request.getRequestDispatcher("path").forward(request, response);
2.重定向:地址改变
response.sendRedirect(path);
13.向request域中存储和取出数据
- request.setAttribute("name", "value");
request.getAttribute("name");
request方法总结的更多相关文章
- 利用Filter和拦截器,将用户信息动态传入Request方法
前言: 在开发当中,经常会验证用户登录状态和获取用户信息.如果每次都手动调用用户信息查询接口,会非常的繁琐,而且代码冗余.为了提高开发效率,因此就有了今天这篇文章. 思路: 用户请求我们的方法会携带一 ...
- nodejs -- http模块. request() 方法 , get方法.
1. request方法: 提交评论到慕课网: var http = require('http'); var querystring = require('querystring'); var po ...
- Ext.Ajax.request方法 参数
json数据服务器回传的方法. 在api总指出回传的格式{success;true,data:{clientName: "Fred. Olsen Lines", portOfL ...
- 20191011-构建我们公司自己的自动化接口测试框架-Action的request方法封装
Action模块 封装接口request方法,根据传入的参数调用不同的请求方法,因为项目特色,我们公司的接口都是get和post方法,所以仅仅封装了get和post方法: import request ...
- Asp.net Request方法获取客户端的信息
Response.Write("客户端计算机名:" + Request.UserHostName + "<BR />"); Response.Wri ...
- 如何在JS中获取Request方法
方法 function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = ne ...
- 基于Promise封装uni-app的request方法,实现类似axios形式的请求
https://my.oschina.net/u/2428630/blog/3004860 uni-app框架中 安装(项目根目录下运行) npm install uni-request --save ...
- 微信小程序--后台交互/wx.request({})方法/渲染页面方法 解析
小程序的后台获取数据方式get/post具体函数格式如下:wx.request({}) data: { logs:[] }, onLoad:function(){ this.getdata(); } ...
- 获取Session和request方法
action中的几种写法 //第一种很少用public class LoginAction1 extends ActionSupport { private Map request; ...
- HttpServletRequest request方法详解
//1.获取请求参数 //获取参数的单个值,如有多个则只返回第一个 String parameter1 = request.getParameter("demo"); //获取参数 ...
随机推荐
- 基于windows fiber的协程(coroutine)实现
一个非常简单,但是实用的协程实现,使用Windows的*Fiber函数族(linux可以稍微改一下用*context函数族). fco.h #ifndef _MSC_VER #error " ...
- Git的一些用法(下)
(4) 提交分支 提交分支命令 : 将本地的分支提交到 GitHub中; git push origin experiment (5) 分支合并移除 合并分支命令 : 合并分支之后, 分支中有的文件在 ...
- 2018年1月17日总结 css3里transition 和animation 区别
transition 和animation两个CSS3属性经常被用到实际项目中,想把它整理出来. 1.先介绍transition >>>>> a. 在做项目中经常会遇见 ...
- Windows下Anaconda安装 python + tensorflow CPU版
下载安装Anaconda 首先下载Anaconda,可以从清华大学的镜像网站进行下载. 安装Anaconda,注意安装时不要将添加环境变量的选项取消掉. 安装完成之后,在安装目录下cmd,输入: co ...
- redis 学习笔记(一)
redis 基本类型 String 基本操作: GET 获取存储在给定键中的值 SET 设置存储在给定键中的值 DEL 删除存储在给定键中的值 List 基本操作: LPUSH/RPUSH 从左/右推 ...
- (二)Audio子系统之new AudioRecord()(Android4.4)
在上一篇文章<(一)Audio子系统之AudioRecord.getMinBufferSize>中已经介绍了AudioRecord如何获取最小缓冲区大小,接下来,继续分析AudioReco ...
- [转] ScalaTest测试框架
[From] https://blog.csdn.net/hany3000/article/details/51033610 ScalaTest测试框架 2016年04月01日 02:49:35 阅读 ...
- 使用python uiautomation从钉钉网页版提取公司所有联系人信息
之前写了一个提取QQ群里所有人信息的脚本 https://www.cnblogs.com/Yinkaisheng/p/5114932.html 今天写一个从钉钉网页版提取公司所有人通讯录的脚本,,本脚 ...
- 文献综述二十:基于UML技术的客户关系管理系统实现
一.基本信息 标题:基于UML技术的客户关系管理系统实现 时间:2015 出版源:电子设计工程 文件分类:uml技术的研究 二.研究背景 设计出可应用与银行和储户之间沟通的客户关系管理系统,从而实现对 ...
- 《大数据日知录》读书笔记-ch3大数据常用的算法与数据结构
布隆过滤器(bloom filter,BF): 二进制向量数据结构,时空效率很好,尤其是空间效率极高.作用:检测某个元素在某个巨量集合中存在. 构造: 查询: 不会发生漏判(false negativ ...