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
16
votes
3 answers

How does Spring MVC relate to Service, Controller and Data Access layers in a web application?

I understand the MVC Pattern and also how Spring MVC implements it. However, how do the Rest controller, Data Access Layer and Service Layer fit into this pattern? Is it: Model = Database (e.g. Oracle/MySQL) and Repositories classes Controller =…
java123999
  • 6,974
  • 36
  • 77
  • 121
16
votes
2 answers

RestFuse vs Rest Assured vs MockMVC Rest Service Unit Test Framework

I've been trying to find a simple all purpose unit test framework for Spring MVC based Rest Services I've written. I've been searching online and narrowed it down to: RestFuse (http://developer.eclipsesource.com/restfuse/) Rest Assured…
JackDev
  • 11,003
  • 12
  • 51
  • 68
16
votes
3 answers

How to display a formatted DateTime in Spring MVC 3.0?

I have a Joda-DateTime field in my model and want to display it formatted in a JSP view. I have annotated it with the new @DateTimeFormat annotation: public class Customer { private DateTime dateOfBirth; @DateTimeFormat(style="M-") public…
Florian Fankhauser
  • 3,615
  • 2
  • 26
  • 30
16
votes
2 answers

ajax login with spring webMVC and spring security

I've been using Spring Security 3.0 for our website login mechanism using a dedicated login webpage. Now I need that login webpage to instead be a lightbox/popup window on every webpage in our site where upon logging in I get an AJAX result whether…
at.
  • 50,922
  • 104
  • 292
  • 461
16
votes
2 answers

How to test DeferredResult timeoutResult

I'm implementing long polling as per the Spring blog from some time ago. Here my converted method with same response signature as before, but instead of responding immediately, it now uses long polling: private Map
Tim
  • 19,793
  • 8
  • 70
  • 95
16
votes
4 answers

No "create from template" Spring MVC in Intellij Idea 15?

In IntelliJ Idea 14, I could use the following: File > New Project > Spring > Create project from template > Spring MVC To create a template Spring MVC application with Maven. Is this feature somewhere else now? The problem is, if I don't use the…
Kevin Van Ryckegem
  • 1,915
  • 3
  • 28
  • 55
16
votes
11 answers

How to pass JVM arguments in SpringBOOT

I would like to pass JVM arguments in the main spring boot class where we will be starting the spring boot application. Could you please share how to set JVM arguments in spring boot application? I tried the below options and there is no…
SpringForLiving
  • 599
  • 2
  • 5
  • 12
16
votes
2 answers

learning Spring's @RequestBody and @RequestParam

I'm editing a web project that uses Spring and I need to adding some of Spring's annotations. Two of the ones I'm adding are @RequestBody and @RequestParam. I've been poking around a little and found this, but I still don't completely understand…
Josh
  • 163
  • 1
  • 1
  • 4
16
votes
1 answer

Using Spring @RestController to handle HTTP GET with ZonedDateTime parameters

I'm creating an endpoint that will receive dates to do some filtering in the server side. The code looks like this: @RequestMapping( value = "/test", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE,…
Andrés Soto
  • 954
  • 1
  • 10
  • 20
16
votes
3 answers

Priority of Various Sources in PropertySources

Spring has introduced a new annotation @PropertySources for all classes marked as @Configuration since 4.0. It takes different @PropertySource as argument. @PropertySources({ @PropertySource("classpath:application.properties"),…
azi
  • 929
  • 1
  • 11
  • 31
16
votes
1 answer

How to call @SendTo from Normal Request Call i.e @RequestMapping

I have implemented Web Socket using Spring MVC and it is working fine for me i.e work from one browser to another browser which is open for those socket using this code. @MessageMapping("/hello") @SendTo("/topic/greetings") public…
Charnjeet Singh
  • 3,056
  • 6
  • 35
  • 65
16
votes
4 answers

Does spring mvc have response.write to output to the browser directly?

I am using spring mvc with freetemplate. In asp.net, you can write straight to the browser using Response.Write("hello, world"); Can you do this in spring mvc?
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
16
votes
3 answers

External library folder for Spring Boot

I wonder how to externalize all jdbc drivers for my Spring Boot applications, I would not like to insert jdbc drivers into my fat jar once the application is built. Is there any way to set a java vm parameter, informing which external folder should…
Carlos Alberto
  • 7,761
  • 13
  • 52
  • 72
16
votes
1 answer

spring-boot without template engine

I have a Spring-Boot app that is apparently way out of the norm. It's Spring-MVC, but I don't want to use velocity,thymeleaf or anything. Ideally I would just use HTML. Then I use jQuery to make my AJAX calls to my REST services, and then fill in…
sonoerin
  • 5,015
  • 23
  • 75
  • 132
16
votes
1 answer

HandlerInterceptor.afterCompletion() in spring MVC changes response code

I am using spring MVC framework. I want to log error statuses whenever exception is thrown, so afterCompletion method is used in HanlderInterceptor. @Override public void afterCompletion( final HttpServletRequest request, final HttpServletResponse…
subhashlg26
  • 993
  • 1
  • 11
  • 25