request有个getParameter()方法,怎么就没有一个setParameter方法呢?我是在做一个登录后自动转发的功能
比如有个链接死这样的: /example.jsp?id=111
如果用户没有登录则先跳转到登录页面
完成登录后系统自动转发到这个链接
现在发现如果用<jsp:forward>标签和request.getRequestDispatcher(" /example.jsp?id=111").forward(request,response);后都把id这个参数丢失了
也就是id没有传到example.jsp中
请问,我该用什么方法才能在example.jsp中获得id的值啊?
比如有个链接死这样的: /example.jsp?id=111
如果用户没有登录则先跳转到登录页面
完成登录后系统自动转发到这个链接
现在发现如果用<jsp:forward>标签和request.getRequestDispatcher(" /example.jsp?id=111").forward(request,response);后都把id这个参数丢失了
也就是id没有传到example.jsp中
请问,我该用什么方法才能在example.jsp中获得id的值啊?
<jsp:forward page="example.jsp>;
<jsp:param name="id" value="<%=id%>;"/>;
</jsp:forward>;
那我如果有多个参数呢?可以写成这样吗?
<jsp:forward page="example.jsp>
<% for(int i= ...... ) %>
<jsp:param name="..." value="<%=...%>;"/>
<% } %>
</jsp:forward>我是想,如果jsp的这个标签能够向请求加入参数
那servlet中肯定也有方法能够set参数,但我就是没有找到这个setParameter方法
Object obj=request.getAttribute("xx");
String url=request.getParameter("url");
session.setAttribute("url",url);
%>
然后在你以前登录成功应该转向的那个页面(例如是loginafter.jsp)上添加:
<%
String url=(String)session.getAttribute("url");
%><script type="text/Jscript">
var forward=<%=url%>;
function jumpHtml()
{
if(forward!=null){
window.location="/example.jsp?id=111";
}
}
</script>最后在该页面(loginafter.jsp)的<body>里调用这个函数:
<body onLoad= jumpHtml()>
正解