方法1)

  request.getRequestURL();

方法2)

     request.getScheme()+"://"+request.getServerName()+":"

    +request.getServerPort()+request.getContextPath()+request.getServletPath();

    其中 

  getScheme()                     http
  getServerName()               localhost
  getServerPort()                 8080
  request.getContextPath()   /Struts2_0300_Path

      request.getServletPath()    /path.jsp

 

两者输出均为 http://localhost:8080/Struts2_0300_Path/path.jsp

若只想获取其中的一部分路径 则只能用第二种方法

相关文章:

  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-02-26
  • 2021-11-30
猜你喜欢
  • 2022-02-06
  • 2022-12-23
  • 2021-11-30
  • 2022-02-23
  • 2022-12-23
相关资源
相似解决方案