你用response.sendRedirect的时候,session失效 应该在response.sendRedirect之前用java.lang.String response.encodeRedirectURL(java.lang.String url)方法encode url 具体用法 encodeRedirectURL public java.lang.String encodeRedirectURL(java.lang.String url)Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is seperate from the encodeURL method. All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies. Parameters: url - the url to be encoded. Returns: the encoded URL if encoding is needed; the unchanged URL otherwise.
应该在response.sendRedirect之前用java.lang.String response.encodeRedirectURL(java.lang.String url)方法encode url
具体用法
encodeRedirectURL
public java.lang.String encodeRedirectURL(java.lang.String url)Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is seperate from the encodeURL method.
All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies. Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.
他好象试销的机会少点
我的感觉
to yanchang(笨笨):由于我们这中间保存的数据挺多,如果用这种形式太麻烦了。
解决办法是,将验证,写信息,读信息也时bean的*.java中即在你的com.SessionBean中首次登陆时做验证,成功后将信息写入session如
HttpSession session;//成员变量
String zgmc="";public void SetSession()
{
session.setMaxInactiveInterval(1000);//设置session时间属性
session.setAttribute("zgmc", zgmc );
......
}
jsp取session的函数为
void SetSession()
{
session.setAttribute("zgmc", zgmc );
......
}
public String getZgmc()
{
zgmc=session.getAttribute("zgmc").toString();//异常什么的要处理,我只简单提一下
return zgmc;}
void SetSession()
{
session.setAttribute("zgmc", zgmc );
......
}
呵