|
|
@@ -6,6 +6,7 @@ import com.mrxu.framework.boot.web.ServletUtils;
|
|
|
import com.mrxu.framework.common.util.BaseCode;
|
|
|
import com.mrxu.framework.common.util.BusinessException;
|
|
|
import com.mrxu.framework.common.util.StrFunc;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
@@ -76,6 +77,7 @@ public class WebExceptionHandler {
|
|
|
return rendError(BaseCode.ERROR);
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
public Object rendError(BaseCode code,String msg) {
|
|
|
HttpServletRequest request = ServletUtils.getRequest();
|
|
|
if(ServletUtils.isAjaxRequest(request)) {
|
|
|
@@ -83,9 +85,16 @@ public class WebExceptionHandler {
|
|
|
}
|
|
|
else {
|
|
|
ModelAndView modelAndView = new ModelAndView();
|
|
|
+ modelAndView.addObject("code", code.getCode());
|
|
|
modelAndView.addObject("message", msg);
|
|
|
modelAndView.setViewName("error/500.html");
|
|
|
|
|
|
+ //没有权限
|
|
|
+ if(BaseCode.ERR_FORBIDDEN.getCode() == code.getCode()) {
|
|
|
+ ServletUtils.getResponse().sendRedirect("/logout");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
//未登录
|
|
|
if(BaseCode.ERR_NOT_AUTH.getCode() == code.getCode()) {
|
|
|
StringBuffer source = request.getRequestURL();
|