个人技术分享

今天点击菜单的时候不小心点开了一个不存在的页面,然后看到浏览器给的一个默认的404页面

后端的程序员都觉得这页面太丑了,那么怎么能自定义404页面呢?

很简单,在我们的springboot的静态资源目录下创建一个error包,然后在/error下面创建一个文件404.html

为了偷懒,直接把那个默认页面复制下来了,然后再加一点简单的字~

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>404-页面找不到了</title>
    </head>

    <body>
        <h1>Whitelabel Error Page</h1>
        <p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>
        <div id="created">Wed May 15 23:27:21 CST 2024</div>
        <div>There was an unexpected error (type=Not Found, status=404).</div>
        <div style="font-size: 200px;">页面走丢了~</div>
    </body>
</html>

再次打开不存在的页面,查看页面效果: