//全局捕获异常类
@ControllerAdvice
public class CatchExceptions {
@ExceptionHandler(RuntimeException.class)
@ResponseBody
public Map<String,Object> resultCatchExceptions(){
Map<String,Object> result = new HashMap<String, Object>();
result.put("code","500");
result.put("error","系统错误。");
return result;
}
添加 freemarker 模板引擎
1.导入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
2.在templates目录下新建一个 .ftl 页面
3.传值