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
15
votes
4 answers

Delete Method Cors issue in Rest Controller

I have some Rest endpoints in my project which I call from a client application in another server. I have successfully disabled Cors using the @CrossOrigin annotation, and all the methods work fine except the Delete method which throws the following…
zakaria amine
  • 3,412
  • 2
  • 20
  • 35
15
votes
2 answers

ClassCastException: org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder

I try to create simple user login and registration page. But I cannot create user using services method. I have a service for creating new user. @Service public class LocalUserDetailsService implements UserService…
Ulphat
  • 734
  • 1
  • 7
  • 26
15
votes
2 answers

Run Spring4MVC with Angular 2 on a single server

I am new to angular2, I want to know what is the possible file structure for SpringMVC4 with angular 2? As shown in image, it will work for Angular 1.x but file structure of Angular 2 is quite different and its component driven, and I am using…
user6709592
15
votes
4 answers

@EventListener for AuthenticationSuccessEvent or InteractiveAuthenticationSuccessEvent not fired

I have this listener in the context of Spring: package listeners; import java.util.Date; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import…
Sergio Sánchez Sánchez
  • 1,694
  • 3
  • 28
  • 48
15
votes
4 answers

Log restful endpoints on container startup in a Spring application

I've a Spring application that expose restful endpoints through @RequestMapping annotation in Controller classes. I wish that were logged into the console, at server startup, all the endpoints of all the application's controller. I use a tomcat…
Alberto Giantin
  • 151
  • 1
  • 1
  • 3
15
votes
8 answers

Postman: Required request part 'file' is not present

I wanted to upload an image to my Rest API through postman. I am using spring boot framework. Here is the screen shot: I also have not set any any headers as I found in other stack overflow answers that it gives multipart boundary error. Now,…
Number945
  • 4,631
  • 8
  • 45
  • 83
15
votes
1 answer

How to reload a @Value property from application.properties in Spring?

I have a spring-boot application. Under the run folder, there is an additional config file: dir/config/application.properties When the applications starts, it uses the values from the file and injects them into: @Value("${my.property}") private…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
15
votes
6 answers

Programmatically restart Spring Boot application / Refresh Spring Context

I am trying to programmatically restart my Spring Application without having the user to intervene. Basically, I have a page which allows to switch the mode of the application (actually meaning switching the currently active profile) and as far as I…
Crembo
  • 5,198
  • 3
  • 26
  • 30
15
votes
3 answers

What is difference between HandlerInterceptor and HandlerInceptorAdaptor in Spring MVC?

Both HandlerInterceptor and HandlerInterceptorAdaptor has preHandle and postHandle methods. But I am not able to understand what is the difference between them with respect to implementation.
pankaj12
  • 183
  • 2
  • 3
  • 9
15
votes
9 answers

Spring MVC file upload - Unable to process parts as no multi-part configuration has been provided

So I'm a newbie to Spring and I'm trying to get file upload working for my project (I'm using Spring Tool Suite btw.) and when submitting a form all I'm getting is: HTTP Status 500 - Could not parse multipart servlet request; nested exception is…
kbijoch
  • 193
  • 1
  • 1
  • 8
15
votes
3 answers

Spring using @Value annotation in Filter

I am currently working on a Spring project and I am making a new filter that checks if a valid JWT has been sent in the request. I am running into an issue where I can't get a value from my application.yml file using the @Value annotation like…
David Jones
  • 4,275
  • 6
  • 27
  • 51
15
votes
2 answers

Warn about non-static ConfigurationClassPostProcessor declarations on @Configuration classes

I use Spring 4.2.6.RELEASE. During initialization of my app I get such a warning: [WARN] org.springframework.context.annotation.ConfigurationClassPostProcessor enhanceConfigurationClasses: Cannot enhance @Configuration bean definition …
Marek Raki
  • 3,056
  • 3
  • 27
  • 50
15
votes
2 answers

Mixing Spring MVC + Spring Data Rest results in odd MVC responses

I have a two JPA entities, one with a SDR exported repository, and another with a Spring MVC controller, and a non-exported repository. The MVC exposed entity has a reference to the SDR managed entity. See below for code reference. The problem…
bvulaj
  • 5,023
  • 5
  • 31
  • 45
15
votes
4 answers

Howto get rid of ?

Up to now, has caused plenty of trouble for me, so I would like to get rid of it. Although the spring framework docs clearly say what it is supposed to be doing, a listing of tags actually summar
Ta Sas
  • 9,573
  • 15
  • 51
  • 73
15
votes
3 answers

How to decorate all requests to take a value from header and add it in the body parameter?

Background I'm creating RESTful services using Spring MVC. Currently, I have the following structure for a controller: @RestController @RequestMapping(path = "myEntity", produces="application/json; charset=UTF-8") public class MyEntityController { …
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332