为什么页面不能跳转?

J_2004 2005-07-14 05:51:28
我在标签中验证登陆,为什么条件成立却不跳转
jsp页面:
<%@ taglib uri="/WEB-INF/check.tld" prefix="user" %><user:check />...
*标签前面没有空
标签:
....
public int doStartTag() throws JspTagException {
try {
HttpSession session=pageContext.getSession();
boolean islogin=true;
if(session.getAttribute("userinfo")==null){
islogin=false;
}
if(!islogin){
pageContext.forward("../user/login.jsp");
}
} catch (IOException e) {
e.printStackTrace();
throw new JspTagException("doEndTag()标签出错!",e);
} catch (ServletException e) {
e.printStackTrace();
throw new JspTagException("doEndTag()标签出错!",e);
}
return SKIP_PAGE;
}
.....
...全文
237 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanchao2001 2005-07-18
  • 打赏
  • 举报
回复
<attribute>
<name>p1</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
J_2004 2005-07-18
  • 打赏
  • 举报
回复
up
J_2004 2005-07-15
  • 打赏
  • 举报
回复
1.
<tag>
<name>check</name>
<tagclass>com.xxx.mailuser.tag.Check</tagclass>
<bodycontent>jsp</bodycontent>
<attribute>
<name>p1</name>
<required>false</required>
</attribute>
<info>
hello
</info>
</tag>
2.
<tag>
<name>check</name>
<tagclass>com.xxx.mailuser.tag.Check</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>p1</name>
<required>false</required>
</attribute>
<info>
hello
</info>
</tag>


不报错就是不跳转
shoulders 2005-07-15
  • 打赏
  • 举报
回复
可能是配置有问题。
J_2004 2005-07-15
  • 打赏
  • 举报
回复
toi sghys(冥府左使) ( ) :

你的我试了,打印出了“没通过验证”
但就是没有跳转,和我的结果一样
什么原因?你是怎么配置的?
sghys 2005-07-14
  • 打赏
  • 举报
回复
也许是配置有误,给你参照下我的吧?

public class ValidSession extends TagSupport {
public int doStartTag() throws JspException {
HttpSession session = pageContext.getSession();
if ((session != null)
&& (session.getAttribute(Constants.SESSION_KEY) != null)) {
System.out.println("已通过验证");
return EVAL_PAGE;
} else {
try {
pageContext.forward("/login.jsp");
System.out.println("没通过验证");

} catch (Exception ex) {
ex.printStackTrace();
}
return SKIP_PAGE;
}

}
}
sghys 2005-07-14
  • 打赏
  • 举报
回复
doStartTag() 方法所在的类要继承TagSupport类

J_2004 2005-07-14
  • 打赏
  • 举报
回复
提示错误:
java.lang.IllegalStateException: Cannot forward after response has been committed
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
org.apache.jsp.coremail.maillist_jsp._jspService(maillist_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
好像之前没有输出任何内容啊?

81,092

社区成员

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

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