1、总览

2、application.properties

spring.mvc.view.prefix=/WEB-INF/pages/
spring.mvc.view.suffix=.jsp
#关闭whitelabel Error page
server.error.whitelabel.enabled=false
#默认never,无法输出trace
server.error.include-stacktrace=always

3、controller

@Controller
public class MyController {
@RequestMapping("/")
public String handler (Model model) {
throw new RuntimeException("test exception");
}
}

4、error.jsp

因为spring boot 提供了一个默认的mapping:/error,因此,我们起的错误jsp页面的文件名为error.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<html>
<head>
<style>
table td{
vertical-align:top;
border:solid 1px #888;
padding:10px;
}
</style>
</head>
<body>
<h1>My Error Page</h1>
<table>
<tr>
<td>Date</td>
<td>${timestamp}</td>
</tr>
<tr>
<td>Error</td>
<td>${error}</td>
</tr>
<tr>
<td>Status</td>
<td>${status}</td>
</tr>
<tr>
<td>Message</td>
<td>${message}</td>
</tr>
<tr>
<td>Exception</td>
<td>${exception}</td>
</tr>
<tr>
<td>Trace</td>
<td>
<pre>${trace}</pre>
</td>
</tr>
</table>
</body>
</html>

5、执行

当执行http://localhost:8080/时,报错:

当执行不存在资源时:

springboot 自定义错误jsp页面的更多相关文章

  1. SpringBoot自定义错误页面,SpringBoot 404、500错误提示页面

    SpringBoot自定义错误页面,SpringBoot 404.500错误提示页面 SpringBoot 4xx.html.5xx.html错误提示页面 ====================== ...

  2. springboot自定义错误页面

    springboot自定义错误页面 1.加入配置: @Bean public EmbeddedServletContainerCustomizer containerCustomizer() { re ...

  3. SpringBoot自定义错误信息,SpringBoot适配Ajax请求

    SpringBoot自定义错误信息,SpringBoot自定义异常处理类, SpringBoot异常结果处理适配页面及Ajax请求, SpringBoot适配Ajax请求 ============== ...

  4. SpringBoot配置使用jsp页面技术

    SpringBoot配置使用jsp页面技术 1.pom配置 package配置必须为war类型 添加依赖 <packaging>war</packaging> <depe ...

  5. Springboot - 自定义错误页面

    Springboot 没找到页面或内部错误时,会访问默认错误页面.这节我们来自定义错误页面. 自定义错误页面 1.在resources 目录下面再建一个 resources 文件夹,里面建一个 err ...

  6. springboot自定义错误页面(转)

    方法一:Spring Boot 将所有的错误默认映射到/error, 实现ErrorController @Controller @RequestMapping(value = "error ...

  7. SpringBoot启动访问JSP页面,直接进入页面或者访问不到,报404,并且加载tomcat插件tomcat-embed-jasper也不行

    这个问题花费了两天的时间,解决路径: 我用的是SpringBoot1.5.2,SpringMVC和Spring,tomcat启动插件都是默认的版本,Spring是4.3.7,jdk是1.7.0_80, ...

  8. ASP.net MVC自定义错误处理页面的方法

    在ASP.NET MVC中,我们可以使用HandleErrorAttribute特性来具体指定如何处理Action抛出的异常.只要某个Action设置了HandleErrorAttribute特性,那 ...

  9. Springboot+MyBatis+mysql+jsp页面跳转详细示例

           SpringBoot与MyBatis搭建环境,底层数据库为mysql,页面使用JSP(官网上不推荐使用jsp),完成从数据库中查询出数据,在jsp页面中显示,并且实现页面的跳转功能. 项 ...

随机推荐

  1. kibana 删除document或者type

    // 删除某个document DELETE /索引名称/type名称/document编号(id) // 删除整个type PUT 索引名称/type名称/_delete_by_query?conf ...

  2. Python django 安装 mysqlclient 失败

    使用命令安装失败: C:\Program Files (x86)\Python\Python37-\Scripts>pip3..exe install mysqlclient Collectin ...

  3. Metasploit学习笔记——社会工程学

    1.社会工程学攻击案例——伪装木马 Linux命令终端输入命令msfvenom -l payloads用来列出攻击载荷,grep命令用来查询所需要的攻击载荷,条件是windows系统.要有回连至监听主 ...

  4. luogu P2765 魔术球问题

    题目中没有说球的上限是多少,只告诉了柱子,那么我们就应该以柱子为界去增加球,考虑将每两个能组成完全平方数的点连边,就形成了一个DAG(有向无环图),由于是DAG,可以转换为最小覆盖问题,即最多有n条路 ...

  5. Day3-K-Can you solve this equation? HDU2199

    Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and ...

  6. 攻防世界web新手练习区(2)

    弱认证:http://111.198.29.45:43769/ 打开是这个页面: 用户名输入1,密码输入2,试试看.会提示你用户名为admin.接下来用burp对密码进行爆破,发现弱口令0123456 ...

  7. Adapter之GridAdapter

    前言: 在我们写界面的时候想让我们展示的页面是网格的,这是我们可以使用GridAdapter,这个和listView的使用有相似之处,如果学过ListView的话还是很简单的 正文: 下面我们来看看G ...

  8. P1062 最简分数

    P1062 最简分数 转跳点:

  9. OBS Studio 24.0 RC1 发布 – 有大惊喜

    导读 对于那些使用OBS Studio进行跨平台直播和屏幕录制需求的人来说,OBS Studio 24.0即将推出,但首先发布的是他们的候选版本,以审查进入这一重大更新的新功能. OBS Studio ...

  10. 一个平凡计算机爱好者的linux进步之路

    我从小就对计算机特别感兴趣,小的时候梦想就是拥有一台属于自己的电脑.无奈那时候农村条件限制,学校.家庭都不配备电脑.只好悄悄的跑去网吧研究一番,但毕竟时间有限,生活费有限,也不可能经常去网吧玩,在网吧 ...