关于Session的问题(急!~)

benben001 2002-02-04 05:00:04
我在上一个页面上用了个
session.setAttribute("sql",String.valueOf(sql));
保存变量
到下一个页面去读的时候用这个
String sql = session.getAttribute("sql");
为什么会出错呢,用
object sql = session.getAttribute("sql");
又说我没有这个类
该怎么读过来这个字符串呢
...全文
53 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuanzi 2002-02-04
  • 打赏
  • 举报
回复
同意!
yanchang 2002-02-04
  • 打赏
  • 举报
回复
必须造型的,(String)session.getAttribute("sql");

gzwrj 2002-02-04
  • 打赏
  • 举报
回复
String sql = (String)session.getAttribute("sql");

getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Returns the object bound with the specified name in this session, or null if no object is bound under the name.
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name
Throws:
IllegalStateException - if this method is called on an invalidated session
redstarstar 2002-02-04
  • 打赏
  • 举报
回复
String sql = (String)session.getAttribute("sql");

81,122

社区成员

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

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