以前一个好好的网站,最近突然出现问题。(JSP + Servlet + Apache + Tomcat)
通过看日志,显示Exception抛出的位置,发现原来是request.getSession(false);这一句返回了一个null引用。
不知道这是为什么。
如果把这一句改成request.getSession(true);则肯定不会返回一个null引用,但是返回的Session却是一个全新的,根本没有页面post上来的任何信息,即在调用getAttribute的时候又会抛出NullPointerException。
请问一下为什么getSession方法一直得不到正确的Session呢?
通过看日志,显示Exception抛出的位置,发现原来是request.getSession(false);这一句返回了一个null引用。
不知道这是为什么。
如果把这一句改成request.getSession(true);则肯定不会返回一个null引用,但是返回的Session却是一个全新的,根本没有页面post上来的任何信息,即在调用getAttribute的时候又会抛出NullPointerException。
请问一下为什么getSession方法一直得不到正确的Session呢?
public HttpSession getSession(boolean create)Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.Parameters:
true - to create a new session for this request if necessary;
false - to return null if there's no current session帮组文档上的
false的意思是,如果当前没有session就返回null
同意上述公约者·申请加入!
QQ群号:25922618(一群已经满)
请加备用群:17615698
我更改了IE的安全设置和Cookie设置, 都设置到最低, 但还是不行.
有没有哪位大哥大姐知道是怎么回事啊?
请高人指点一二,谢谢。