66import org .springframework .http .ResponseEntity ;
77import org .springframework .stereotype .Controller ;
88import org .springframework .web .bind .annotation .RequestMapping ;
9+ import org .springframework .web .bind .annotation .RequestMethod ;
910import org .springframework .web .bind .annotation .ResponseBody ;
1011import org .springframework .web .context .request .RequestAttributes ;
1112import org .springframework .web .context .request .ServletRequestAttributes ;
1819 * Error controller, based on https://stackoverflow.com/questions/31134333/this-application-has-no-explicit-mapping-for-error/31838439#31838439
1920 */
2021@ Controller
21- public class AppErrorController implements ErrorController {
22+ public class AppErrorController implements ErrorController {
2223
2324 /**
2425 * Error Attributes in the Application
@@ -40,7 +41,7 @@ public AppErrorController(ErrorAttributes errorAttributes) {
4041 * @param request
4142 * @return
4243 */
43- @ RequestMapping (value = ERROR_PATH , produces = "text/html" )
44+ @ RequestMapping (value = ERROR_PATH , produces = "text/html" , method = RequestMethod . GET )
4445 public ModelAndView errorHtml (HttpServletRequest request ) {
4546 return new ModelAndView ("/errors/error" , getErrorAttributes (request , false ));
4647 }
@@ -50,7 +51,7 @@ public ModelAndView errorHtml(HttpServletRequest request) {
5051 * @param request
5152 * @return
5253 */
53- @ RequestMapping (value = ERROR_PATH )
54+ @ RequestMapping (value = ERROR_PATH , method = RequestMethod . GET )
5455 @ ResponseBody
5556 public ResponseEntity <Map <String , Object >> error (HttpServletRequest request ) {
5657 Map <String , Object > body = getErrorAttributes (request , getTraceParameter (request ));
@@ -68,7 +69,6 @@ public String getErrorPath() {
6869 return ERROR_PATH ;
6970 }
7071
71-
7272 private boolean getTraceParameter (HttpServletRequest request ) {
7373 String parameter = request .getParameter ("trace" );
7474 if (parameter == null ) {
@@ -102,4 +102,4 @@ private HttpStatus getStatus(HttpServletRequest request) {
102102 }
103103 return HttpStatus .INTERNAL_SERVER_ERROR ;
104104 }
105- }
105+ }
0 commit comments