页面未重定向

发布于 2024-11-03 20:53:44 字数 3017 浏览 1 评论 0原文

org.apache.jasper.JasperException:JSP 中的异常:/views/header.jsp:14

11:         <a href="<%=request.getContextPath()%>">Home</a> | 
12:         <% String username=(String)session.getAttribute("formdata");
13:         String admin="admin";
14:         if(username.equals(" ")){
15:             
16:             String logout="http://localhost:8080/NewsBank/logout.do";
17:             response.sendRedirect(logout);

堆栈跟踪:

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:801)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.lang.NullPointerException
    org.apache.jsp.views.addStory_jsp._jspService(addStory_jsp.java:93)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:801)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

org.apache.jasper.JasperException: Exception in JSP: /views/header.jsp:14

11:         <a href="<%=request.getContextPath()%>">Home</a> | 
12:         <% String username=(String)session.getAttribute("formdata");
13:         String admin="admin";
14:         if(username.equals(" ")){
15:             
16:             String logout="http://localhost:8080/NewsBank/logout.do";
17:             response.sendRedirect(logout);

Stacktrace:

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:801)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.lang.NullPointerException
    org.apache.jsp.views.addStory_jsp._jspService(addStory_jsp.java:93)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:801)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗳卜坏 2024-11-10 20:53:44

username 对我来说似乎是null

检查是否无效

if(username != null || "".equals(userName)){
//your code
}

建议:

  • 我们有过滤器 为此(身份验证检查)目的,为什么要破坏 jsp ?

  • 避免在 JSP 上编写 javacode


参见另外

username seems null to me.

Check for nullity

if(username != null || "".equals(userName)){
//your code
}

Suggestions:

  • We have Filter for this (authentication check) purpose why spoiling jsp ?

  • Avoid writing javacode on JSP


See Also

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文