<%String ref = request.getHeader("REFERER");%>
<input type="button" name="returngo" value="/blog/返回上一页" onclick="javascript:window.location='<%=ref%>'" >
1.
struts Ation中的用法:
Jsp获取上一页的url
String url=request.getHeader("Referer");
返回上一页
mapping.findForward(url);
2.
利用javascript
public String jump( String jump)
{
String url=null;
if(jump=="back")
{
url="javascript:history.go(-1);\n"; //返回上一页
}
else if(jump=="home")
{
url="javascript:window.location.href='index.jsp';\n"; //返回首页
}
else if(jump=="")
{
url="";
}
else
{
url="javascript:window.location.href='"+jump+"';\n"; /返回指定页
}
String script_start="<script language=\"javascript\">\n";
String script_end="</script>";
String go=script_start+url+script_end;
return go;
}
在Ation中用法
response.setContentType("text/html; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
String jump = ju.jump("home");
out.println(jump);
posted on 2008-01-10 14:56
李建軍 阅读(2951)
评论(0) 编辑 收藏 所属分类:
jsp