1. 程式人生 > >獲取當前路徑:http://localhost:8081/專案名/

獲取當前路徑:http://localhost:8081/專案名/

    String contextPath = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+
request.getServerPort()+contextPath+"/";
    System.out.println(basePath);// http://localhost:8081/sgcc/