diff --git a/ruoyi-admin/src/main/resources/templates/error/404.html b/ruoyi-admin/src/main/resources/templates/error/404.html index d7b27704d..774a58dfd 100644 --- a/ruoyi-admin/src/main/resources/templates/error/404.html +++ b/ruoyi-admin/src/main/resources/templates/error/404.html @@ -17,7 +17,5 @@ 主页 - - diff --git a/ruoyi-admin/src/main/resources/templates/error/500.html b/ruoyi-admin/src/main/resources/templates/error/500.html index 5618070ab..f59b91b93 100644 --- a/ruoyi-admin/src/main/resources/templates/error/500.html +++ b/ruoyi-admin/src/main/resources/templates/error/500.html @@ -18,7 +18,5 @@ 主页 - - diff --git a/ruoyi-admin/src/main/resources/templates/error/business.html b/ruoyi-admin/src/main/resources/templates/error/business.html new file mode 100644 index 000000000..f47cde785 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/error/business.html @@ -0,0 +1,20 @@ + + + + + + RuoYi - 403 + + + + + +
+

操作异常!

+ +
+ [[${errorMessage}]] +
+
+ + diff --git a/ruoyi-admin/src/main/resources/templates/error/unauth.html b/ruoyi-admin/src/main/resources/templates/error/unauth.html index b662c1229..ca14e5526 100644 --- a/ruoyi-admin/src/main/resources/templates/error/unauth.html +++ b/ruoyi-admin/src/main/resources/templates/error/unauth.html @@ -18,7 +18,5 @@ 返回主页 - - diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java index 1f01e56da..50fbed545 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java @@ -77,10 +77,21 @@ public class GlobalExceptionHandler * 业务异常 */ @ExceptionHandler(BusinessException.class) - public AjaxResult businessException(BusinessException e) + public Object businessException(HttpServletRequest request, BusinessException e) { log.error(e.getMessage(), e); - return AjaxResult.error(e.getMessage()); + + if (ServletUtils.isAjaxRequest(request)) + { + return AjaxResult.error(e.getMessage()); + } + else + { + ModelAndView modelAndView = new ModelAndView(); + modelAndView.addObject("errorMessage", e.getMessage()); + modelAndView.setViewName("error/business"); + return modelAndView; + } } /**