Download an Image or a File with Spring MVC Spring MVC 1. Overview Serving static files to the client can be done in a variety of ways, and using a Spring Controller isn’t necessarily the best available option. However, sometimes the controller route is necessary – and that’s what we’re… Continue Reading spring-controller-return-image-file

Spring MVC Custom Validation 1. Overview Generally, when we need to validate user input, Spring MVC offers standard predefined validators. However, when we need to validate a more particular type input, we have the possibility of creating our own, custom validation logic. In this article, we’ll do just that –… Continue Reading spring-mvc-custom-validator

A Quick Guide to Spring MVC Matrix Variables 1. Overview The URI specification RFC 3986 defined URI path parameters as name-value pairs. Matrix variables is a Spring coined term and an alternative implementation for passing and parsing URI path parameters. Matrix variables support became available in Spring MVC 3.2 and… Continue Reading spring-mvc-matrix-variables

A Guide To Spring Redirects 1. Overview This article will focus on implementing a Redirect in Spring and will discuss the reasoning behind each strategy. Further reading: Redirect to Different Pages after Login with Spring Security Example of how to Redirect to different pages after Login with Spring Security. Read… Continue Reading spring-redirect-and-forward

Spring MVC @PathVariable with a dot (.) gets truncated 1. Overview In this short tutorial, we’ll discuss a common problem when working with Spring MVC – when using a Spring @PathVariable with a @RequestMapping to map the end of a request URI that contains a dot, we’ll end up with a partial value in our… Continue Reading spring-mvc-pathvariable-dot

Changing Spring Model Parameters with Handler Interceptor Spring MVC 1. Introduction In this tutorial we are going to focus on the Spring MVC HandlerInterceptor. More specifically, we will change Spring MVC’s model parameters before and after handling a request. If you want to read about HandlerInterceptor’s basics, check out this… Continue Reading spring-model-parameters-with-handler-interceptor

Guide to Spring Handler Mappings 1. Introduction In Spring MVC, the DispatcherServlet acts as front controller – receiving all incoming HTTP requests and processing them. Simply put, the processing occurs by passing the requests to the relevant component with the help of handler mappings. HandlerMapping is an interface that defines… Continue Reading spring-handler-mappings