问题描述,我点击如下的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~
通过request最多只能得到action名字,action里的方法名没法得到,rights/rights.do这里,有没有什么办法获取完整的地址啊?我想得到的地址是完整的http://localhost:8080/rights/rights.do?method=main,呵呵,问题不上档次,请勿见怪
O(∩_∩)O~
解决方法:
1 改为post提交
2 将方法名参数改在隐藏表单域里面。<input type='hidden' name='method' value='main'>
<%@ 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就可以得到完整的项目路劲了
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;
}