[BAEL-18367] Moving articles from rest-spring-** pt 4

This commit is contained in:
Sjmillington
2019-12-08 10:42:40 +00:00
parent 8de37745a1
commit 05c5002b73
35 changed files with 190 additions and 562 deletions
@@ -0,0 +1,24 @@
package com.baeldung.web.controller.status;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class ExampleController {
@RequestMapping(value = "/controller", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity sendViaResponseEntity() {
return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE);
}
@RequestMapping(value = "/exception", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity sendViaException() {
throw new ForbiddenException();
}
}
@@ -0,0 +1,10 @@
package com.baeldung.web.controller.status;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.FORBIDDEN, reason = "To show an example of a custom message")
public class ForbiddenException extends RuntimeException {
private static final long serialVersionUID = 6826605655586311552L;
}