Nov 21

* Update pom.xml, add xml and json media types to support returned information type

1. add dependency of dataformat xml
2. In controller, add produces to GetMapping / PostMapping

GET
Accept application/xml or json


* How to handle exceptions (screenshot)

1. custom description message
2. modify createUser in controller
3. test POST request with empty names    json and xml

* Create exception for each service class (Create UserService Exception)

1.create UserServiceException.java
2. modify exception to UserServiceException in createUser

* How to handle this specific user service exception
1. create AppExceptionsHandler
2. test POST request and check response message without accept header

1. Create ErrorMessage.java
2. modify AppExceptionsHandler
3. test POST again


* handle all other exceptions
1. add handleOtherExceptions method
2. modify createUser in controller
3. test POST



Reference
https://crunchify.com/why-and-for-what-should-i-use-enum-java-enum-examples/

Comments

Popular posts from this blog

Portlet Edit Mode (Portlet preference) to replace Portlet configuration

GoGo Shell & What can be deleted in Liferay Instance