HttpServletRequest get URL (parameter, path, port number, protocol, etc.) details

Text 1 2021-02-22 23:22:32
httpservletrequest url parameter path port


HttpServletRequest obtain URL Common methods are as follows :

Suppose the address requested by the client url:http://localhost:8082/TestReq/MyServlet/username=51gjie&age=20

// The customer asked for URL, Does not include parameter data
request.getRequestURL // return http://localhost:8082/TestReq/MyServlet

// take URL The domain name and the following parameters are intercepted , The rest is URI
request.getRequestURI // return /TestReq/MyServlet

// return URL The string in the parameter part of , Must be GET Your request is valid , Otherwise an error
request.getQueryString // return username=51gjie&age=20

// Returns the name of the requested scheme , Such as http,ftp,https etc.
request.getScheme // return http

//HTTP The name of the requested method , The default is GET, You can also specify PUT or POST
request.getMethod // return GET

// That is, the name of inclined rod machining process
request.getContextPath // return /TestReq

// Server hostname
request.getServerName // return localhost

// Server web The access port of the application
request.getServerPort  request.getLocalPort // return 8082

// Return the protocol name and version of the request , Such as HTTP/1.1 etc.
request.getProtocol // return HTTP/1.1

// The full path string of the project deployment is followed by the string in the parameter
request.getRealPath("/WEB-INF") // return d:\omc_jboss\server\default\.\deploy\TestReq.war\WEB-INF

// This part of the string after the project and before the parameter
request.getServletPath // return /MyServlet

// The string contains the URL Relevant additional information
request.getPathInfo // return null

// request URL Length of body content , Only right POST and PUT Type of request is valid
request.getContentLength // return -1

版权声明
本文为[Text 1]所创,转载请带上原文链接,感谢
https://qdmana.com/2021/02/20210222134708889e.html

  1. Vue3元件(九)Vue + element-Plus + json = 動態渲染的表單控制元件
  2. 我的 HTTP/1.1 好慢啊!
  3. Vue為何採用非同步渲染
  4. The response status was 0. Check out the W3C XMLHttpRequest Level 2 spec for
  5. Front end monastery
  6. How to quickly understand a new front end project?
  7. webpack4.X核心工具库之tapable实例对象Hook
  8. webpack4.X核心工具库之tapable实例对象Hook
  9. C++使用libcurl进行http通讯
  10. Can be directly used in HTML special character table Unicode character set
  11. C++使用libcurl进行http通讯
  12. Java traverses list < string > and takes out the string elements in it, and splices them with ","
  13. Self taught web front end more than two months, talk about my harvest and progress, learning summary
  14. vue 中使用 css 变量
  15. 深入了解React中state和props的更新
  16. 百度分享不支持https的解决方案
  17. [practical] ABAP mail sending (HTML + attachment)
  18. [practical] ABAP mail sending (HTML + attachment)
  19. Teach you how to select products with less profit and competition in Amazon Product Development (1)
  20. 【微前端】微前端最终章-qiankun指南以及微前端整体探索
  21. 【微前端】微前端最终章-qiankun指南以及微前端整体探索
  22. Vue-Cli 创建vue3项目
  23. Go in the front of the progress of u boot v7.0 U disk boot disk production tools
  24. 使用NTLM的windows身份验证的nginx反向代理
  25. Rust教程:针对JavaScript开发人员的Rust简介
  26. 使用 Serverless Framework 部署个人博客到腾讯云
  27. #研發解決方案#易車前端監控系統
  28. Vue changes localhost to IP address and cannot access
  29. JavaScript进阶学习
  30. HTML5 from entry to proficient, realize annual salary 10W +, zero basic students must see
  31. Vue:vuex状态数据持久化插件vuex-persistedstate
  32. Vue source code analysis - start
  33. Vue -- the child component calls the method of the parent component and passes parameters --- props
  34. React-Native 获取设备当前网络状态 NetInfo
  35. 高性能 Nginx HTTPS 调优 - 如何为 HTTPS 提速 30%
  36. How to learn HTML5? How can Xiaobai start HTML5 quickly?
  37. HTML + CSS detailed tutorial, this article is enough, but also quickly save
  38. JavaScript高级:JavaScript面向对象,JavaScript内置对象,JavaScript BOM,JavaScript封装
  39. Why Vue uses asynchronous rendering
  40. JavaScript高级:JavaScript面向对象,JavaScript内置对象,JavaScript BOM,JavaScript封装
  41. vue判断elementui中el-form是否更新变化,变化就提示是否保存,没变就直接离开
  42. 算法题:两数之和——JavaScript及Java实现
  43. 高性能 Nginx HTTPS 调优
  44. Why Vue uses asynchronous rendering
  45. day 31 jQuery进阶
  46. day 30 jQuery
  47. CSS whimsy -- using background to create all kinds of wonderful backgrounds
  48. Why are more and more people learning front end?
  49. What do you do with 4K front-end development?
  50. 8 years of front-end development knowledge precipitation (do not know how many words, keep writing it...)
  51. What is the annual salary of a good web front end?
  52. Front end novice tutorial! How to get started with web front end
  53. Will the front end have a future?
  54. Is the front end hard to learn?
  55. Seven new Vue combat skills to improve efficiency in 2021!
  56. Is front end learning difficult?
  57. How about the process of Web front-end development and self-study?
  58. Front end learning route from zero basis to proficient
  59. What is the basis of learning front end?
  60. What knowledge points need to be learned for self-study front end? How long can I become a front-end Engineer?