java獲取請求的url地址

原文鏈接:https://www.cnblogs.com/pxblog/archive/2019/03/13/10523013.html

1.獲取全路徑
request.getRequestURL(); //得到http://localhost:8888/CRM/loginController/login

2.獲取協議名和域名
request.getScheme(); //得到協議名 例如:http
request.getServerName(); //得到域名 localhost

3.獲取請求所有參數 //map類型
request.getParameterMap()

4.獲取項目名
request.getContextPath(); // /CRM

5.獲取請求方法
request.getServletPath(); // /loginController/login

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章