springboot+freemarker

//全局捕获异常类
@ControllerAdvice
public class CatchExceptions {

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Map resultCatchExceptions(){

        Map result = new HashMap();
            result.put("code","500");
            result.put("error","系统错误。");

        return result;
    }

添加 freemarker 模板引擎

1.导入依赖


            org.springframework.boot
            spring-boot-starter-freemarker
        

2.在templates目录下新建一个 .ftl 页面springboot+freemarker_第1张图片

3.传值springboot+freemarker_第2张图片

你可能感兴趣的:(springboot+freemarker)