Showing posts with the label @ResponseStatus

Spring @ResponseStatus Annotation Example

In this section we will learn about @ResponseStatus  Annotation.   The  @ResponseStatus  marks a method or exception class with the status code and reason message that should be returned. The status code is applied to the HTTP response when the handler method is invoked, or whenever the specified exception is thrown. It overrides status information set by other means, like ResponseEntity or redirect. Here is a sample code snippet: @ResponseStatus ( value = HttpStatus . NOT_FOUND ) public class UserNotFoundException extends RuntimeException { } The following example creates a Spring Boot web application which uses  @ResponseStatus  annotation . Project Directory Pom.xml <? xml version ="1.0" encoding ="UTF-8" ?> < project xmlns ="" xmlns:xsi ="" xsi:schemaLocation ="