关于request的一个函数???

ggyy 2002-03-14 03:42:41
A.jsp中:(A的表单请求B.jsp)
request.setAttribute()
设置的属性再什么地方能得到???
(二)
如果在A.jsp中
不通过表单
通过response.sendRedirect();怎么传递参数???
...全文
23 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ggyy 2002-03-14
  • 打赏
  • 举报
回复
感谢回答!
第2问已经解决!
ggyy 2002-03-14
  • 打赏
  • 举报
回复
(一):
A.jsp:
<%@ page contentType="text/html; charset=EUC-JP" %>
<html>
<head>
<title>
Jsp1
</title>
</head>
<body>
<h1>
JBuilder Generated JSP
</h1>
<form action="aa.jsp"method="post">
<%
request.setAttribute("shibushi","dsfds");
%>

<input type="submit"value="dfds">
</form>
</body>
</html>
aa.jsp:
<%@ page contentType="text/html; charset=EUC-JP" %>
<html>
<head>
<title>
aa
</title>
</head>
<body>
<h1>
JBuilder Generated JSP
</h1>
<%

String name=null;
if(request.getAttribute("shibushi")!=null)
name=request.getAttribute("shibushi").toString();
%>
<%=name%>
</body>
</html>
结果为:null呀!

southline 2002-03-14
  • 打赏
  • 举报
回复
Answer:
(1)request.setAttribute()'s value can get in the next page only,not like session can get in all page.

(2)you can do like this:
response.sendRedirect("B.jsp?para=theValue")

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧