You are on page 1of 9

TANVI DHINGRA

704619

DAY 6:
Implementing Rest Services (POST,GET,PUSH,DELETE)
DemoApplication.java

Student.java (POJO)
TANVI DHINGRA
704619

StudentRepo.java

Application.properties

StudentController.java
TANVI DHINGRA
704619

POST REQUEST MAPPING

GET REQUEST MAPPING


TANVI DHINGRA
704619

Records added to MySQL Database

DELETE REQUEST MAPPING

Recorded Deleted from database


TANVI DHINGRA
704619

PUT REQUEST MAPPING

Data updated in database


TANVI DHINGRA
704619

DAY 7:
Implementing Validations and Exception Handling
Required Dependency

Used validation annotations like:


@NotNull​,@NotEmpty (list field not empty) ​,@NotBlank (string not empty)​
@Min and @max​,@Pattern​,@Email

Messages as per Validation (Problem with Last Name size)


TANVI DHINGRA
704619

Problem with email:

● Defining a class annotated with @ControllerAdvice​​


● Class to extend ResponseEntityExceptionHandler. ​
● Annotate the method with @ExceptionHandler - allows to define which method
should be called in case of an error​​
● Create a custom error POJO class Error
TANVI DHINGRA
704619
TANVI DHINGRA
704619

Exception Handled:

You might also like