Java WebService gets request object WebService gets HttpServletRequest object

HaHa_ Sir 2020-11-12 22:42:44
java webservice gets request object

 Java WebService obtain request object WebService obtain HttpServletRequest object


One 、 Problem description

In the use of WebService When , Meet the need to pass pictures , The idea is to return the host name of the server , Tried Static get request object , But when the client calls , Yes, we can't get it request Of . Then it needs to pass WebService To obtain request object .


Two 、 Code implementation

1、 as follows :

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
private WebServiceContext webServiceContext;
public HttpServletRequest getRequest() {
MessageContext messageContext = webServiceContext.getMessageContext();
HttpServletRequest request = (HttpServletRequest)messageContext.get(MessageContext.SERVLET_REQUEST);
return request;


2、 Get request object , The others can be solved synchronously .




setAttribute(String name,Object)

Set name to name Of request Parameter values for

getAttribute(String name)

Return from name The specified property value


return request The name set of all properties of an object , The result is an instance of enumeration


Return all of the client's Cookie object , The result is a Cookie Array


Returns the encoding of characters in the request


Return requested Body The length of

getHeader(String name)

get HTTP Protocol defined file header information

getHeaders(String name)

Returns the request Header All values , The result is an instance of enumeration


Return so request Header Name , The result is an instance of enumeration


Return the requested input stream , Used to get the data in the request


How to get data from client to server

getParameter(String name)

Get the client to send to the server name The specified parameter value


Get the names of all parameters passed from the client to the server , The result is an instance of enumeration

getParametervalues(String name)

Acquired name All values for the specified parameter


Get the protocol name by which the client transfers data to the server


Get query string


Get the address of the client that issued the request string


Get client's IP Address


Get the name of the client

getSession([Boolean create])

Return and request related Session


Get the name of the server


Get the path of the script file requested by the client


Get the port number of the server

removeAttribute(String name)

Delete a property in the request


more : SpringMVC Static acquisition in request object



本文为[HaHa_ Sir]所创,转载请带上原文链接,感谢

  1. css单位
  2. CSS unit
  3. 前端验证集合
  4. Front end validation collection
  5. Front end learning (4) -- response line, response head, response body
  6. Lesson 27: using time measuring tools to explore available spare time
  7. Lesson 28: annual professional value assessment
  8. CSS 单位
  9. CSS unit
  10. 前端工具集合
  11. Front end Tools Collection
  12. Introduction to HTTP message format
  13. Introduction to new features of HTML5
  14. Common instructions for Vue
  15. Introduction of bootstrap Blazer component library
  16. HTML5 速览
  17. HTML5 quick view
  18. HTML表格自动排序
  19. For less than $1700, create a private cloud with openstack
  20. Basic learning of JavaScript (1)
  21. 前端编程之路一一HTML标签分类
  22. Front end Programming: HTML tag classification
  23. Don't bother to find the front-end framework in the background. Use fantasy admin in 2021
  24. ColSpan and rowspan merging cells of HTML form elements
  25. JavaScript 日期时间格式化
  26. JavaScript date time formatting
  27. Classification of front end interview questions - html2
  28. HTML5 flexible layout
  29. CSS block elements
  30. HTML5 form detailed tutorial
  31. HTML5 form detailed tutorial
  32. HTML5新增的元素表
  33. New element table in HTML5
  34. 3D轮播插件vue-carousel-3d非官方最全文档
  35. 3D carousel plug-in vue-carousel-3d
  36. Uniapp (Vue general) integrates Tencent location service SDK -- multi platform small program general
  37. Slowhttptest slow attack tool use details
  38. HTML summary (2)
  39. Overview of CSS3
  40. Front end abnormal monitoring system
  41. 免费网站部署和免费数据库Serverless云存储资源汇总整理
  42. Free website deployment and collection of free database serverless cloud storage resources
  43. Vux form -- a form solution of base vux
  44. 可以直接用于HTML中的特殊字符表 unicode字符集
  45. Can be directly used in HTML special character table Unicode character set
  46. Detailed explanation of HTTP protocol
  47. HTTP request header and request response header
  48. CSS background深度解析
  49. Python web/HTML GUI
  50. Front end standard 2: HTML you know and don't know
  51. Some HTML tags
  52. HTML标签之table
  53. Table of HTML tag
  54. DataTables of jQuery plug-in
  55. Unity calls Google's free translation API (HTTPS interface). Young people don't speak martial arts. How can they speak in multiple languages
  56. Linux entry most commonly used commands, do not learn a bunch of useless commands
  57. Piziheng embedded: a list of common short-range wireless communication protocols (Wi Fi / Bluetooth / ZigBee / thread...)
  58. JS & jQuery Foundation
  59. CSS text properties