diff --git a/ruoyi-admin/src/main/resources/templates/error/404.html b/ruoyi-admin/src/main/resources/templates/error/404.html index d7b27704..774a58df 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 5618070a..f59b91b9 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 00000000..f47cde78 --- /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 b662c122..ca14e552 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 1f01e56d..50fbed54 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; + } } /**