美文网首页
配置404、500错误页面

配置404、500错误页面

作者: 掵鈡紸錠_ | 来源:发表于2018-11-26 13:03 被阅读0次

    在web.xml配置一下:

    image.png

    如果需要拷贝代码复制下面的:

    <error-page>
    
        <error-code>404</error-code>
    
        <location>/WEB-INF/jsp/404.jsp</location>
    
    </error-page>
    
    <error-page>
    
        <exception-type>java.lang.Throwable</exception-type>
    
        <location>/WEB-INF/jsp/500.jsp</location>
    
    </error-page>
    
    <error-page>
    
        <error-code>500</error-code>
    
        <location>/WEB-INF/jsp/500.jsp</location>
    
    </error-page>
    

    如果是jsp页面需要在页面加上isErrorPage="true"(html页面不用加),如果不加会跳到浏览器自身的404/500页面

    <%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8" isErrorPage="true"%>
    
    image.png

    相关文章

      网友评论

          本文标题:配置404、500错误页面

          本文链接:https://www.haomeiwen.com/subject/kgfbqqtx.html