mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
2019-7-16更新 支持本地存储
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package cn.hellohao.controller;
|
||||
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 错误页面拦截
|
||||
* */
|
||||
|
||||
@Controller
|
||||
class MainsiteErrorController implements ErrorController {
|
||||
|
||||
@RequestMapping("/error")
|
||||
public String handleError(HttpServletRequest request){
|
||||
//获取statusCode:401,404,500
|
||||
Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
|
||||
if(statusCode == 401){
|
||||
return "/401";
|
||||
}else if(statusCode == 404){
|
||||
return "/404";
|
||||
}else if(statusCode == 403){
|
||||
return "/403";
|
||||
}else{
|
||||
return "/500";
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public String getErrorPath() {
|
||||
return "/error";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user