在这个页面http://www.XXXX.com/wiki/topic/230800上, 打开一个联接, 
进入struts的ACTION, 
我想获取的URL是“/wiki/topic/230800”
请问如何能办到

解决方案 »

  1.   

    1.首先让你的action获得Request对象.其实很简单,就是实现ServletRequestAware.
    当你实现了这个接口后会需要实现一个方法.
    public void setServletRequest(HttpServletRequest arg0) {
    }
    这里Struts就把HttpServletRequest 给你了.你自己可以定义一个HttpServletRequest request来保存arg0.2.当你有了这个request对象后,通过request.getURI( )返回HTTP请求行中请求URI的部分。
    如果请求的URL为:http://localhost:8080/webapp/login
    那么分别调用request.getContextPath( )、request.getServletPath( ) 、
    request.getURI( )、request.getURL( )分别返回什么路径?这几个方法都是在HttpServletRequest接口中定义的。1.request.getURI( )返回HTTP请求行中请求URI的部分。上例中该方法将返回/webapp/login。2.request.getContextPath( )返回web应用程序的路径,上例中该方法将返回/webapp。3.request.getServletPath( ) 返回Servlet的路径。上例中该方法将返回/login。4.request.getURL( )返回请求的URL,上例中即为http://localhost:8080/webapp/login
      

  2.   

    大家还没理解我的意思, 在这个页面http://www.XXXX.com/wiki/topic/230800上, 
    有一个链接,比如说http://www.xxxx.com/download.do?k=k
    我一点这个链接, 我要获取的是 wiki/topic/230800而不是/download.do
      

  3.   

    这个 可以在 你的 download.do 这个链接后面
    加上这个页面的 url 作为参数传递到你的action! 好像只能这么办了!......
      

  4.   

    那就在Javascript里进行处理吧.
    location.href就是http://www.XXXX.com/wiki/topic/230800.
    你再进行字符串处理即可.
    var href = location.href;
    href = href.repalce("//","@@");
    href = href.substring(href.indexOf("/")+1);
    这个href 就应该是你需要的了
      

  5.   

    String   url=request.getHeader("Referer");
    正则表达式取
      

  6.   

    你在跳到http://www.XXXX.com/wiki/topic/230800这个页面之前
    可以先用request.setAttribute()方法将当前页面保存起来
    然后到http://www.XXXX.com/wiki/topic/230800页面后在取出来就是了
    我也做过这样的需求,我是这样实现的,不知道可不可以帮上忙