mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
2021-03-15更新
This commit is contained in:
@@ -2,8 +2,10 @@ package cn.hellohao.controller;
|
||||
|
||||
import cn.hellohao.exception.StorageSourceInitException;
|
||||
import cn.hellohao.utils.Print;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -50,6 +52,20 @@ public class ExceptionHandling {
|
||||
return e.getMessage();
|
||||
}
|
||||
|
||||
@ExceptionHandler
|
||||
public String test3(HttpRequestMethodNotSupportedException e,Model model){
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView("/index");
|
||||
Print.Normal("URL访问类型不正确:"+ e.getMessage());
|
||||
//e.printStackTrace();
|
||||
modelAndView.addObject("error","URL访问类型不正确。");
|
||||
model.addAttribute("error","URL访问类型不正确。");
|
||||
//返回错误信息,并显示给用户
|
||||
//return e.getMessage();
|
||||
return "exception";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @ExceptionHandler
|
||||
// public String methodArgumentNotValid(BindException e) {
|
||||
|
||||
Reference in New Issue
Block a user