How to bind @RequestParam to object in Spring

Do you have multiple parameters annotated with @RequestParam in a request mapping method and feel it isn’t readable?

The annotation looks pretty straightforward when there’s one or two input parameters expected in a request but when the list gets longer you might feel overwhelmed.

You cannot use the @RequestParam annotation inside objects but it doesn’t mean you’re left with no other solution. In this post, I’m going to show you how to replace multiple @RequestParams with an object.

Continue reading “How to bind @RequestParam to object in Spring”

Custom validation annotation in Spring

Although built-in validation support in Spring is largely sufficient for standard use cases, sooner or later you will run into a situation when the sets of validation annotations provided by JSR 303 or Hibernate Validator aren’t enough. In this post you will learn how to create a simple constraint annotation served by a custom validator with access to the Spring context of a Spring Boot application.

Continue reading “Custom validation annotation in Spring”