【问题标题】:Servlet exception mappingServlet 异常映射
【发布时间】:2019-05-09 02:30:38
【问题描述】:

我想在发生异常时显示特定的 jsp。我有一个自定义异常。 我已经在 web.xml 中映射了它

  <error-page>
    <location>/WebContents/A3/jsp/test.jsp</location>
  </error-page>

这是我的自定义异常

public class TestFileListException extends ServletException

这就是我的 servlet 中的内容

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        throw new TestFileListException("werw");
}

请帮助我指出我的流程/逻辑中有什么问题。 谢谢!

【问题讨论】:

    标签: java jsp exception servlets


    【解决方案1】:

    试试这个:

    <error-page>
        <exception-type>java.lang.Throwable</exception-type>
        <location>/WebContents/A3/jsp/test.jsp</location>
    </error-page>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-01
      • 2022-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-01
      • 1970-01-01
      • 2012-09-12
      相关资源
      最近更新 更多