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"); //获取参数 ...
随机推荐
- Codeforces Round #549 (Div. 2)C. Queen
C. Queen time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- bzoj1800飞行棋
题目链接 简单模拟 真的不敢相信ahoi09年的题竟然是这个难度 首先,一个必须要知道的定理是:圆上只有直径所对的圆周角是直角. 然后就很显然了, 只有两条不重合的直径上的四个点才能组成一个矩形, 所 ...
- HDU6184【Counting Stars】(三元环计数)
题面 传送门 给出一张无向图,求 \(4\) 个点构成两个有公共边的三元环的方案数. 题解 orz余奶奶,orz zzk 首先,如果我们知道经过每条边的三元环个数\(cnt_i\),那么答案就是\(\ ...
- ZooKeeper参数
原文连接:https://www.cnblogs.com/skyl/p/4854553.html ZooKeeper参数调优 zookeeper的默认配置文件为zookeeper/conf/zoo ...
- UIResponder笔记
UIResponder是什么 可以响应UIEvent的类,是UIApplication, UIView及UIViewController的父类.它的父类是NSObject 管理第一响应者. 是否是第一 ...
- 【医学影像】《Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning》论文笔记
这篇论文的作者是张康教授为首的团队,联合国内外众多医院及科研机构,合力完成,最后发表在cell上,实至名归. 从方法的角度上来说,与上一篇博客中的论文很相似,采用的都是InceptionV3模型,同时 ...
- 高阶篇:4.1)QFD质量功能展开-总章
本章目的:了解QFD概念和作用,为FMEA打下基础. 1.QFD定义 质量功能展开QFD(Quality Function Deployment),是把顾客或市场的要求转化为设计要求.零部件特性.工艺 ...
- springcloud(二)-最简单的实战
技术储备 Spring cloud并不是面向零基础开发人员,它有一定的学习曲线. 语言基础:spring cloud是一个基于Java语言的工具套件,所以学习它需要一定的Java基础.当然,sprin ...
- rocketmq的消息过滤-sql方式
通常我们会使用Tag过滤 特殊情况下我们也可以使用userproperties+TAGS过滤 , sql92定义 这两种都是在服务器端完成过滤, 对于超大数据量的场景(1小时4000W+)不要在客流端 ...
- 如何让一个div居于页面正中间
如何让一个div居于页面正中间 如何让一个div居于页面中间,我今天说的是让一个div水平居中同时垂直居中,而不是简单的top:50%,left:50%.当然,我们就按一开始的思路写一下:top,le ...