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
2 answers

What's the difference between ModelAndView and ModelMap?

Is ModelMap just the new name in Spring 3 for a ModelAndView? Does the functionality change in Spring 3? Consider this code in a Spring 3 app using a ModelMap: @RequestMapping(value = "/order", method = RequestMethod.GET) public final String…
pnut butter
  • 367
  • 2
  • 5
  • 13
17
votes
2 answers

Elegant way to get Locale in Spring Controller

I'm looking for a cleaner way (in Spring 3.2) to get the current locale than explicitly calling LocaleContextHolder.getLocale() at the start of each Controller method. It has to be compatible with Java annotation, as I'm not using the XML config.…
yetimoner
  • 787
  • 2
  • 9
  • 19
17
votes
3 answers

Implementing plugin architecture in annotation based Spring Boot Application

I want to implement plugin architecture in Spring Boot application. Let me explain my scenario. I have a main application, which starts the server, manages security, etc. The app is like the root of my final product which will include this root app…
yuva
  • 3,108
  • 4
  • 20
  • 35
17
votes
2 answers

Are Spring's MockMvc used for unit testing or integration testing?

Spring has 2 setups for the MockMvc: Standalone setup WebApplicationContext setup In general what kind of testing is MockMvc used for? Unit or Integration? or Both? Am i right in saying that using the standalone setup (running outside the Spring's…
SoftwareDeveloper
  • 1,094
  • 2
  • 15
  • 26
17
votes
3 answers

Reverse AJAX (Comet) and Spring MVC vs. Scala/LIFT?

There is a demo by IBM that shows how easy Reverse AJAX can be used with DWR 2. On the other hand, Scala/LIFT comes with built-in Reverse AJAX capability. Question: Any experience if this works fine with Spring MVC? Question: If you'd start from…
Ta Sas
  • 9,573
  • 15
  • 51
  • 73
17
votes
3 answers

How to build a dynamic URL in Spring MVC?

I am trying to send one URL which I will generate on basis of some dynamic value. But I don't want to hard code it nor want to use response or request object. Example: http://localhost:8585/app/image/{id}/{publicUrl}/{filename} So I want to get…
John Maclein
  • 1,034
  • 3
  • 13
  • 24
17
votes
2 answers

Spring MVC, forward

Is there any difference between public class Controller1 extends AbstractController { @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { …
user12384512
  • 3,362
  • 10
  • 61
  • 97
17
votes
3 answers

How to set @ApiModelProperty dataType to String for Swagger documentation

I am using Spring MVC (via Spring Boot) and have integrated Swagger API documentation using the swagger-spring-mvc library. I have a class that looks something like this: @ApiModel public class CartItem { ... private Money listPrice; // joda…
nerdherd
  • 2,508
  • 2
  • 24
  • 40
17
votes
6 answers

How do I bind collection attributes to a form in Spring MVC

I'm trying to bind one of my model objects to the fields of a form, using Spring-MVC. Everything works fine, except that one of the attributes of the model object is an unordered collection. Doing something like
agnul
  • 12,608
  • 14
  • 63
  • 85
17
votes
4 answers

Spring Controller start processing after response is sent

I am using a Spring MVC controller and want to start the execution of a task in a new thread. However the task should not start immediately but only after the response has been sent to the client. The sequence - in strict temporal order: request…
mreiterer
  • 556
  • 1
  • 4
  • 15
17
votes
2 answers

How to create CommonsMultipartFile object given only a file

I have a junit test method that takes a CommonsMultipartFile object as a parameter. I'm trying to create a FileItem object so I can pass it to the constructor, CommonsMultipartFile(org.apache.commons.fileupload.FileItem fileItem) To do that, I'm…
wsams
  • 2,499
  • 7
  • 40
  • 51
17
votes
2 answers

HTTP Status 500 - ... IllegalArgumentException: Unknown return value type when I use ResponseStatus annotation and return value in spring controller

I have wrote following controller method: @RequestMapping(value = "/member/createCompany/uploadImage1", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public Long handle() { return 1l; } When I request this…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
17
votes
4 answers

Required MultipartFile parameter 'file' is not present in spring mvc

I am trying to add feature of uploading picture to my spring mvc application. jsp part: ...
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
17
votes
1 answer

Spring MVC Execution Order: Filter and Interceptor

I'm developing a spring MVC application that uses a filter implementing javax.servlet.Filter and an Interceptor extending org.springframework.web.servlet.handler.HandlerInterceptorAdapter. As far as I know, the control flow of Spring MVC is…
Emilio
  • 1,024
  • 4
  • 16
  • 33
17
votes
2 answers

Spring REST Service Certificate auth

I have written Spring controller. This get's requests from clients. It's just REST style. This is very good. But I need certificate authentication. Only the clients must have access to the rest service (spring controller), which have client…
grep
  • 5,465
  • 12
  • 60
  • 112