1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.example.Controller;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class AppErrorController implements ErrorController {
private final static String ERROR_PATH = "/error";
@ResponseBody
@RequestMapping(value = ERROR_PATH)
public String errorHtml() {
return "页面不存在";
}
@Override
public String getErrorPath() {
return ERROR_PATH;
}
}