[英]How to fetch localhost:8080 from full URL
我的URL路徑為http:// localhost:8080 / welcome / this / is / a / test
我在Java中的路線是
String domain = httpServletRequest.getServerName();
但有了這個,我得到“localhost”。 我想要端口號,我想在我的字符串中只獲得“localhost:8080”。
它可以在一行代碼中實現
String hostName = request.getHeader("host");
System.out.println(" HostName : " + hostName);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.