Model, ModelMap, and ModelView in Spring MVC 1. Overview In this article, we’ll look at the use of the core org.springframework.ui.Model, org.springframework.ui.ModelMap and org.springframework.web.servlet.ModelView provided by Spring MVC. 2. Maven Dependencies Let’s start with the spring-context dependency in our pom.xml file: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.3.11.RELEASE</version> </dependency> The latest version of… Continue Reading spring-mvc-model-model-map-model-view

Request Method Not Supported (405) in Spring 1. Overview This quick article is focused on a common error – ‘Request Method not Supported – 405′ – that developers face while exposing their APIs for specific HTTP verbs, with Spring MVC. Naturally, we’ll also discuss the common causes of this error. 2. Request… Continue Reading spring-request-method-not-supported-405

Returning Custom Status Codes from Spring Controllers 1. Overview This quick article will demonstrate a few ways to return custom HTTP status codes from Spring MVC controllers. This is often important in order to more clearly express the result of a request to a client and using the full rich… Continue Reading spring-mvc-controller-custom-http-status-code

A Guide to the ViewResolver in Spring MVC 1. Overview All MVC frameworks provide a way of working with views. Spring does that via the view resolvers, which enable you to render models in the browser without tying the implementation to a specific view technology. The ViewResolver maps view names… Continue Reading spring-mvc-view-resolver-tutorial

The Spring @Controller and @RestController Annotations 1. Overview In this quick tutorial, we’ll discuss the difference between @Controller and @RestController annotations in Spring MVC. The first annotation is used for traditional Spring controllers and has been part of the framework for a very long time. The @RestController annotation was introduced… Continue Reading spring-controller-vs-restcontroller

Spring Web Annotations 1. Overview In this tutorial, we’ll explore Spring Web annotations from the org.springframework.web.bind.annotation package. 2. @RequestMapping Simply put, @RequestMapping marks request handler methods inside @Controller classes; it can be configured using: path, or its aliases, name, and value: which URL the method is mapped to method: compatible… Continue Reading spring-mvc-annotations

Spring @RequestParam Annotation 1. Overview In this quick tutorial, we’ll explore Spring’s @RequestParam annotation. Simply put, we can use @RequestParam to extract query parameters, form parameters and even files from the request. We’ll discuss how to use @RequestParam and its attributes. We’ll also discuss the differences between @RequestParam and @PathVariable.… Continue Reading spring-request-param