<address id="zhpbl"></address>
<noframes id="zhpbl">
<address id="zhpbl"><form id="zhpbl"><th id="zhpbl"></th></form></address>

    <em id="zhpbl"></em>

      <address id="zhpbl"><th id="zhpbl"><progress id="zhpbl"></progress></th></address>
      更多精彩內容,歡迎關注:

      視頻號
      視頻號

      抖音
      抖音

      快手
      快手

      微博
      微博

      java獲取請求域名

      文檔

      java獲取請求域名

      java獲取協議名和域名可以通過request.getServerName(); //得到域名localhost,通過request.getScheme(); //得到協議名,例如:http。
      推薦度:
      導讀java獲取協議名和域名可以通過request.getServerName(); //得到域名localhost,通過request.getScheme(); //得到協議名,例如:http。

      很多朋友都想知道java如何獲取請求域名?下面就一起來了解一下吧~

      1、獲取協議名和域名。

      request.getScheme();?//得到協議名?例如:http
      request.getServerName();?//得到域名?localhost

      2、獲取全路徑。

      request.getRequestURL();?//得到http://localhost:8888/CRM/loginController/login

      3、獲取請求所有參數 //map類型。

      request.getParameterMap()

      4、獲取項目名

      request.getContextPath();?//?/CRM

      5、獲取請求方法

      request.getServletPath();?//?/loginController/login

      /**
      ?????*?獲取當前訪問URL?(含協議、域名、端口號[忽略80端口]、項目名)
      ?????*?@param?request
      ?????*?@return:?String
      ?????*/
      ????public?static?String?getServerUrl(HttpServletRequest?request)?{
      ????????//?訪問協議
      ????????String?agreement?=?request.getScheme();
      ????????//?訪問域名
      ????????String?serverName?=?request.getServerName();
      ????????//?訪問端口號
      ????????int?port?=?request.getServerPort();
      ????????//?訪問項目名
      ????????String?contextPath?=?request.getContextPath();
      ????????String?url?=?"%s://%s%s%s";
      ????????String?portStr?=?"";
      ????????if?(port?!=?80)?{
      ????????????portStr?+=?":"?+?port;
      ????????}
      ????????return?String.format(url,?agreement,?serverName,?portStr,?contextPath);
      ????}

      以上就是小編今天的分享,希望能幫到大家。

      文檔

      java獲取請求域名

      java獲取協議名和域名可以通過request.getServerName(); //得到域名localhost,通過request.getScheme(); //得到協議名,例如:http。
      推薦度:
      為你推薦
      資訊專欄
      熱門視頻
      相關推薦
      java獲取路徑 java cssbox java獲取運行時間 java ctp java獲取隨機字符串 java daemon java獲取隨機數 java dashboard java獲得當前路徑 java表單校驗 java dataframe java規則引擎 java dataset java讀取json java讀取本地excel java decaf java調python java decode java decodeuri java delegate java csrf java獲取視頻時長 java crontab java獲取網絡時間 java crash java獲取秒級時間戳 java core java獲取泛型class java corba java cookie java獲取本地ip java controller java獲取本周日期 java context japanese java 微信怎么群發消息 java獲取時間差 java獲取文件名后綴 微博賬號怎么注銷 excel如何換行
      Top 少妇高潮太爽了在线视频