问题描述,我点击如下的url地址:http://localhost:8080/rights/rights.do?method=main
通过request最多只能得到action名字,action里的方法名没法得到,rights/rights.do这里,有没有什么办法获取完整的地址啊?我想得到的地址是完整的http://localhost:8080/rights/rights.do?method=main,呵呵,问题不上档次,请勿见怪
O(∩_∩)O~

解决方案 »

  1.   

    自己再组装下把request。getParametersMap
      

  2.   

    你用 request 是怎么取的?
      

  3.   

    不知道你的什么意思,/rights.do 不是你structs配置的Action路径么?method 是你form里的属性么?main不是method属性的值么?同样等待回答...
      

  4.   

    呵呵,谢谢你的耐心回答,怪我没阐述清楚,/rights.do是Struts里配置的Action路径,method是Form属性,main是action里的方法名。现在我想获取的request路径是完整的路径,http://localhost:8080/rights/rights.do?method=main,期待你的回复,呵呵
      

  5.   

    request是通过页面请求,转到action里取的啊。如果没表述清楚,请多多谅解,并给予指点,呵呵。
      

  6.   

    是啊,所以想得到后面的.do?method=main这个东东啊,呵呵,谢谢你的关注。
      

  7.   

    你用的get方式吧!如果用get方式,写在action的地址不能这样获得参数
    解决方法:
    1 改为post提交
    2 将方法名参数改在隐藏表单域里面。<input type='hidden' name='method' value='main'>
      

  8.   

    request.getServletPath() 试试看 能不能得到
      

  9.   

    在jsp页面头加上
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>引用basePath 
    function sendEmail(){
         location.href="<%=basePath%>order/order!xxxx.action?xxx=${order.orderId};
    }
    这个js就可以得到完整的项目路劲了
      

  10.   

     getRequestURL() 返回类型为StringBuffer的那个
      

  11.   

    我是这么搞的,呵呵,谢谢诸位帮忙:
    String rightsPoint = "";
    Enumeration<?> enu = request.getParameterNames();
    String method = null;
    String paramter = null;
    String localUrl = null;
    while(enu.hasMoreElements()){
     method = (String) enu.nextElement();
     paramter = request.getParameter(method);
     localUrl = request.getServletPath();
     localUrl = localUrl.substring(localUrl.lastIndexOf("/") + 1) + "?" + method + "=" + paramter;
    }