jsp中抛出一个异常

    <%
        String action = request.getParameter("action");
        if ("accountException".equals(action)) {
        //    System.out.println("111");//true
            throw new AccountException("兄弟登陆了");
        }
    %>

    <a href="<%=request.getRequestURI() %>?action=accountException">click</a>

filter捕捉异常,然后传到下一个jsp处理网页

        try {
            chain.doFilter(request, response);
        } catch (Exception e) {
            String message = e.getMessage();
            request.setAttribute("message", message);
            request.getRequestDispatcher("/AccountException.jsp").forward(
                    request, response);
        }

 

相关文章:

  • 2022-01-15
  • 2022-01-11
  • 2021-08-15
  • 2021-11-17
  • 2021-08-05
  • 2021-11-03
  • 2021-10-08
  • 2021-06-17
猜你喜欢
  • 2021-09-27
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案