关于jsp:forward标签

来源:百度知道 编辑:UC知道 时间:2024/06/21 16:35:23
login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="result.jsp">
<jsp:param name="username" value="sss"/>
</jsp:forward>
</body>
</html>

result.jsp
<html>
<head>
</head>
<body>
<% //username: <%= request.getParameter("username")%>
username:${requestScope.username}
</body>
</html>

为什么我用request.getParameter("username")可以取到值,而${requestScope.username} 取不到值呢? 说得清楚者肯定加分,谢谢。

el取的不是参数而是值,就是说不是Parameter而是Parameter。你只有调用了request.setAttribute()方法设置的值才能通过el取得。

开头加上<%@ page isELIgnored="false" %> 试试