-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathHttpErrorHandler.java
More file actions
51 lines (44 loc) · 1.13 KB
/
HttpErrorHandler.java
File metadata and controls
51 lines (44 loc) · 1.13 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.xys.exhandler.controller;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* @author xiongyongshun
* @version 1.0
* @created 16/8/29 13:28
*/
//@Controller
public class HttpErrorHandler implements ErrorController {
private final static String ERROR_PATH = "/error";
/**
* Supports the HTML Error View
*
* @param request
* @return
*/
@RequestMapping(value = ERROR_PATH, produces = "text/html")
public String errorHtml(HttpServletRequest request) {
return "404";
}
/**
* Supports other formats like JSON, XML
*
* @param request
* @return
*/
@RequestMapping(value = ERROR_PATH)
@ResponseBody
public Object error(HttpServletRequest request) {
return "404";
}
/**
* Returns the path of the error page.
*
* @return the error path
*/
@Override
public String getErrorPath() {
return ERROR_PATH;
}
}