在初次使用EL时发现了一个问题。。requestScope传值无效
爱花的石头 2010-07-05 07:01:38 我在两个页面中测试使用EL。。。结果发现 Form表单action提交到另一页面和利用 <A> 标签时。。requestScope无效
不能在另一页面中使用 requestScope 获得值 。。。,,而 sessionScope 和 applicationScope 都可以用。。。。
当我利用 request.getRequestDispatcher("showEl.jsp").forward(request,response); 这个进行页面跳转时就有可以用了。。
这是为什么 ??
以下是代码 :
<body>
<%
request.setAttribute("request","在request中设置的值");
session.setAttribute("session","在session中设置的值 ");
application.setAttribute("application","在application中设置的值 ");
%>
<form action="Jsp/showEl.jsp">
<tr>
<td>用户名:</td>
<td><input type="text" name="txtName"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="txtPwd"/></td>
</tr>
<tr><td colspan="2"><input type="submit" value="测试 El——JSTL"/></td></tr>
</form>
<a href="Jsp/showEl.jsp?request=123">测试利用超连接传值</a>
<%
// request.getRequestDispatcher("showEl.jsp").forward(request,response); 不使用时不能传值 ,使用后可传值
%>
</body>
</html>
另一个页码的代码:
<table>
<tr>
<td>在这里测试EL——JSTL,显示传过来的值</td>
</tr>
<tr>
<td>${param.txtName }</td>
</tr>
<tr>
<td>${param.txtPwd }</td>
</tr>
<tr>
<td>${requestScope.req}</td>
</tr>
<tr>
<td>${sessionScope.session}</td>
</tr>
<tr>
<td>${applicationScope.application}</td>
</tr>
</table>
页面显示图:
在这里测试EL——JSTL,显示传过来的值
在session中设置的值
在application中设置的值
问题: 为什么 表单的action 和 a 标签进行页面跳时无效??难道这两个是重定向的??请高手说明一下。