2
org.springframework.expression.spel.SpelEvaluationException
:EL1008E: プロパティまたはフィールド「タイムスタンプは」タイプ のJavaのオブジェクト上で見つけることができません.util.HashMap ' - おそらくpublicではないでしょうか?
これは私のコードで、私のプロジェクトにはSpring SecurityとThymeleafをインポートしています。あなたのビュー名は「エラー」ではなく「/エラー」でなければなりません
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<meta charset="UTF-8" />
<title>统一异常处理</title>
</head>
<body>
<h1> 系统异常 </h1>
<div th:text="${url ?: '未捕捉到URL'}"></div>
<div th:text="${exception == null ? '暂无异常信息' : exception.message}"></div>
</body>
</html
@GetMapping("/test")
public String test() throws Exception {
throw new Exception("发生错误");
}
@ControllerAdvice
public class GlobalExceptionHandler {
private static final String DEFAULT_ERROR_VIEW = "/error";
private static final Logger LOGGER = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest request, Exception e) {
LOGGER.error("系统异常", e);
ModelAndView mav = new ModelAndView();
mav.addObject("exception", e);
mav.addObject("url", request.getRequestURI());
mav.setViewName(DEFAULT_ERROR_VIEW);
return mav;
}
}
https://stackoverflow.com/questions/35882793/error-while-redirecting-to-custom-error-page-in-spring-boot-applicationこれで問題を解決できます。 –