Skip to content

Commit acf021a

Browse files
author
codedrinker
committed
添加异常处理
1 parent afee54f commit acf021a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.nfnote.controller;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.boot.web.servlet.error.ErrorController;
5+
import org.springframework.http.MediaType;
6+
import org.springframework.stereotype.Controller;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
9+
/**
10+
* Created by codedrinker on 2020/08/16.
11+
*/
12+
@Controller
13+
@RequestMapping("${server.error.path:${error.path:/error}}")
14+
public class CustomizeErrorController implements ErrorController {
15+
16+
@Value("${domain}")
17+
private String domain;
18+
19+
@Override
20+
public String getErrorPath() {
21+
return "error";
22+
}
23+
24+
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE)
25+
public String errorRedirect() {
26+
return "redirect:" + domain;
27+
}
28+
}

0 commit comments

Comments
 (0)