Questions tagged [spring-mvc]

A framework for building Java web applications based on the Model-View-Controller (MVC) pattern. It promotes flexible and decoupled code from the underlying view technologies.

Spring MVC is an action-based (as opposed to component-based) web framework built on top of the Spring IOC Container. MVC stands for Model View Controller, a long standing design pattern that layers an application separating presentation concerns from business logic see Portland Pattern Repository's MVC Entry

The latest stable version is 5.1.4 and was released in January 2019, and the current docs can be found in the MVC section of the Spring Reference.

Spring Version 5.0 fully supports Java 9 features, this release now requires Java SE 8.

Major Spring Releases

  • First Release : Year 2004
  • Spring 2.0 : Intoduced namespaces and support.
  • Spring 2.5 : Anotation Based Configuration
  • Spring 3.0 : Strong Java 5+ foundation across framework, Introduced @Configuration model
  • Spring 3.2 : Java Based Configuration introduced
  • Spring 4.0 : Java 8 Support, removed Deprecated classes.
  • Spring 5.0 : Java 9 Support, reactive programming support

The Spring Framework comprises several modules that provide a range of services:

  • Inversion of Control container: configuration of application components and lifecycle management of objects, done mainly via dependency injection
  • Aspect-oriented programming: enables implementation of cross-cutting routines
  • Data access: working with relational database management systems on the platform using and object-relational mapping tools and with databases
  • Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects
  • Model-view-controller: an HTTP- and servlet-based framework providing hooks for extension and customization for web applications and RESTfull web services.
  • Remote Access framework: configurative RPC-style export and import of Java objects over networks supporting , and HTTP-based protocols including web services ()
  • Convention-over-configuration: a rapid application development solution for Spring-based enterprise applications is offered in the module
  • Batch processing: a framework for high-volume processing featuring reusable functions including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management
  • Authentication and authorization: configurable security processes that support a range of standards, protocols, tools and practices via the Spring Security sub-project (formerly - Acegi Security System for ).
  • Remote Management: configurative exposure and management of Java objects for local or remote configuration via .
  • Messaging: configurative registration of message listener objects for transparent message-consumption from message queues via , improvement of message sending over - - standard APIs
  • Testing: support classes for writing unit tests and integration tests
58288 questions
17
votes
3 answers

Spring Rest Controller inheritance

I have a typed abstract RestController that contains some common logic for processing of all objects of the type. The service for processing is provided through the constructor. During the bean instantiation of the subclass, both constructors are…
Nick
  • 218
  • 1
  • 2
  • 12
17
votes
2 answers

RestTemplate vs WebClient benefits in Servlet based web-mvc app

I'm looking for a clarification on the bolded text in the statement below (I've provided the full paragraph for context only): The RestTemplate is not a good fit for use in non-blocking applications, and therefore Spring WebFlux application should…
Kevin
  • 24,871
  • 19
  • 102
  • 158
17
votes
4 answers

Spring MVC @RequestParam - empty List vs null

By default Spring MVC assumes @RequestParam to be required. Consider this method (in Kotlin): fun myMethod(@RequestParam list: List) { ... } When passing empty list from javaScript, we would call something like: $.post("myMethod", {list:…
Vojtěch
  • 11,312
  • 31
  • 103
  • 173
17
votes
4 answers

Experiences with integrating spring 3 mvc with GWT?

Given: Spring 3.0 mvc has excellent REST support with one of the representation being JSON. GWT simplifies development as UI is developed in java. But by default it uses RPC for client server interaction. But there is an option to use…
MountainRock
  • 594
  • 1
  • 9
  • 24
17
votes
11 answers

Spring Boot custom favicon.ico not showing

I know this question has been asked over and over here and there are several solutions. I've tried several of those except the ones that suggests writing you own configuration bean for this. I don't want to do all that just to display a tiny icon it…
Johan Fredin
  • 573
  • 2
  • 5
  • 12
17
votes
2 answers

How do I enable CORS headers in the Swagger /v2/api-docs offered by Springfox Swagger?

I have the following file in my project: @Configuration @Order(Ordered.LOWEST_PRECEDENCE) public class SwaggerConfig { @Bean public Docket apiSwagger2Documentation() { .... } } And in the Application.java there…
Adrian Smith
  • 17,236
  • 11
  • 71
  • 93
17
votes
2 answers

Spring Boot integration test ignoring secure=false in AutoConfigureMockMvc annotation, get 401

Can't make my @SpringBootTest work. It says authentication is on, which I do not want. I've set it up with @AutoConfigureMockMvc(secure = false) I submit a mock request with some JSON and my integration test should test the whole stack, taking it…
Adam
  • 5,215
  • 5
  • 51
  • 90
17
votes
1 answer

API in Spring Boot Repository vs DAO

I'm trying to design an rest API in spring boot and what to ask about a few design decisions. I am completely confused by the whole difference between DAO vs Repository pattern/design. After hours of reading I still don't really understand the…
Richard
  • 5,840
  • 36
  • 123
  • 208
17
votes
4 answers

What does spring-boot-starter-parent exactly do in pom file?

I'm developing a project which is not Spring boot but also spring mvc. I mean I don't have this class for example in my project: @SpringBootApplication public class Application extends SpringBootServletInitializer { public static void…
ShakibaZar
  • 727
  • 3
  • 9
  • 27
17
votes
1 answer

Cannot get rid of "An Authentication object was not found in the SecurityContext" in a Spring Boot application without @WithMockUser

I have spent a few whole days already trying to figure out what I'm doing wrong, but have no clue why it's not working. First of all, I would like to say that the following configuration is mostly copied from another projects I'm working on, and…
Lyubomyr Shaydariv
  • 20,327
  • 12
  • 64
  • 105
17
votes
1 answer

Session management with Spring Boot?

I want to set up session management and authentication with Spring Boot. Specifically, when the user logs into my web application, they should be able to call my REST API to get data. Furthermore, after a certain period of time, they should be…
Jenna Maiz
  • 792
  • 4
  • 17
  • 38
17
votes
2 answers

Error when using @WebMvcTest annotation on a Spring Boot test class

I've written a test class for a Spring MVC controller by following the "Testing the Spring MVC slice" section described here. The class looks like this: @RunWith(SpringRunner.class) @WebMvcTest(controllers=OurController.class) public class…
pacoverflow
  • 3,726
  • 11
  • 41
  • 71
17
votes
6 answers

How to process a form login using Spring Security / Spring MVC

Simple question, I just need a pointer in the right direction: I have a simple Spring MVC/Spring Security webapp. Initially I set up Spring Security so that the default login page shows and authenticates properly (I implemented the…
David Parks
  • 30,789
  • 47
  • 185
  • 328
17
votes
4 answers

How to return an image in Spring Boot controller and serve like a file system

I've tried the various ways given in Stackoverflow, maybe I missed something. I have an Android client (whose code I can't change) which is currently getting an image like this: HttpURLConnection connection = (HttpURLConnection)…
Manish Patel
  • 4,411
  • 4
  • 25
  • 48
17
votes
2 answers

FilterRegistrationBean is deprecated in Spring Boot 1.4.*

I upgraded Spring Boot dependency in my project and I realized that some classes, such as FilterRegistrationBean, are deprecated. Do you know how can implement a Filter in Spring Boot 1.4.1? Bean of Filter @Bean public FilterRegistrationBean…
pik4
  • 1,283
  • 3
  • 21
  • 56