httpServletRequest.getContextPath() 和 getServletPath() 和 getRequestURL()

        http://localhost:8088/aimili/event/eventList.htm?name=1&key=3&class=5

 

      String url  =  httpServletRequest.getRequestURL().toString();     // url 为 :http://localhost:8088/aimili/event/eventList.htm 

      String  contextPath  =  httpServletRequest.getContextPath();   //   为:/aimili

        String servletPath =  httpServletRequest.getServletPath();    //    为: /event/eventList.htm

        String path =  contextPath  +  servletPath ;


        String query = httpServletRequest.getQueryString();      //  name=1&key=3&class=5


        if (StringUtil.isNotEmpty(query)&& !"null".equals(query)) {  
             path += "?" + query;
       }

  

 

       httpServletRequest.getContextPath()

   

你可能感兴趣的:(java)