request.getContextPath()

request.getScheme():httpまたはhttps; 
request.getServerName():localhostまたはIPアドレスまたはドメイン名、例:www.baidu.com; 
request.getServerPort():ポート番号、例:8080; request.getContextPath ():プロジェクトパス、スラッシュ付き、例:/ test。
例:https://127.0.0.1:8080 / test /



    String path = request.getScheme() + "://" 
                + request.getServerName()
                + ":" + request.getServerPort() 
                + request.getContextPath()
                + "/";

 

おすすめ

転載: blog.csdn.net/qq_29644709/article/details/92745334