</td> </tr> </table> <% } %>
------------------------------------------------------------------------------------------------------- myRedirect.java
package com.util; import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; public class myRedirect //对url的转换类 { public static String dealurl(HttpServletRequest request) { String url = ""; url = request.getRequestURL()+"?"; url +=param(request); if(url.indexOf("&")>-1) url=url.replaceAll("&","@#@");//实际上就是把有&的字符转化成了@#@ return url; } public static String geturl(String url)//这个是还原方法 { if(url.indexOf("@#@")>-1) url=url.replaceAll("@#@","&"); return url; } public static String param(HttpServletRequest request) { String url = ""; Enumeration param = request.getParameterNames();//得到所有参数名 while(param.hasMoreElements()) { String pname = param.nextElement().toString(); url += pname+"="+request.getParameter(pname)+"&"; } if(url.endsWith("&")) { url = url.substring(0,url.lastIndexOf("&")); } return url; } } 这样登录浏览器就会自动转到用户刚刚请求的地址 |