当前位置: 代码迷 >> Java Web开发 >> [求助]有关variable request might not have been initialized
  详细解决方案

[求助]有关variable request might not have been initialized

热度:1031   发布时间:2006-11-10 10:42:40.0
[求助]有关variable request might not have been initialized

程序是这样的
public static void TEST()
{
HttpServletRequest request;
HttpSession Session = request.getSession ("Test");
}

我只是想得到一个SESSION
可是却出错
variable request might not have been initialized
应该是说request没有初始化吧
这个要怎么初始化啊?

还是有其它更好的办法?不要向TEST()传参数

谢谢

搜索更多相关主题的帖子: initialized  variable  request  not  TEST  

----------------解决方案--------------------------------------------------------

明显request没有初始化


----------------解决方案--------------------------------------------------------
这个要怎么初始化啊?
高手们帮帮忙啊

----------------解决方案--------------------------------------------------------

要看你这个方法在什么地方定义的


----------------解决方案--------------------------------------------------------
晕,我不是已经把程序给出来了吗?
public static void TEST()
{
HttpServletRequest request;
HttpSession Session = request.getSession ("Test");
}

它是在一个普通的类里面,

----------------解决方案--------------------------------------------------------
那就得不到了
----------------解决方案--------------------------------------------------------
你的类一般要继承自HttpServlet才好取
----------------解决方案--------------------------------------------------------
  相关解决方案