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

How to match a Spring @RequestMapping having a @pathVariable containing "/"?

I am doing the following request from the client: /search/hello%2Fthere/ where the search term "hello/there" has been URLencoded. On the server I am trying to match this URL using the following request…
yeforriak
  • 1,705
  • 2
  • 18
  • 26
16
votes
4 answers

Is it possible to extend WebMvcConfigurationSupport and use WebMvcAutoConfiguration?

I need to extend the WebMvcConfigurationSupport class too modify two things: @Configuration public class WebConfig extends WebMvcConfigurationSupport { @Override public RequestMappingHandlerMapping requestMappingHandlerMapping() { …
Cory Comer
  • 165
  • 1
  • 2
  • 7
16
votes
4 answers

Spring MVC REST Handing Bad Url (404) by returning JSON

I am developing a REST service using SpringMVC, where I have @RequestMapping at class and method level. This application is currently configured to return error-page jsp configured in web.xml. 404
Himalay Majumdar
  • 3,883
  • 14
  • 65
  • 94
16
votes
4 answers

Open ResponseEntity PDF in new browser tab

I came across a helpful PDF generation code to show the file to the client in a Spring MVC application ("Return generated PDF using Spring MVC"): @RequestMapping(value = "/form/pdf", produces = "application/pdf") public ResponseEntity
user1685185
16
votes
2 answers

How to access system properties in Thymeleaf template?

I need to access system properties in a Thymeleaf template. It would be nice if this was possible so that I don't have to populate the spring mvc model explicitly with properties. I'm trying to use SPEL for this purpose but it's not working.
junkie
  • 809
  • 2
  • 8
  • 19
16
votes
7 answers

Trying to create REST-ful URLs with multiple dots in the "filename" part - Spring 3.0 MVC

I'm using Spring MVC (3.0) with annotation-driven controllers. I would like to create REST-ful URLs for resources and be able to not require (but still optionally allow) file extension on the end of the URL (but assume HTML content type if no…
nickdos
  • 8,348
  • 5
  • 30
  • 47
16
votes
1 answer

How to design push notifications using Atmosphere

I want to use atmosphere to develop a notification System. I am very new to Atmosphere so apologies if I am wrong somewhere. What i understood is when a Actor publishes something I save the notification action to the database. What i don't…
Saurabh Kumar
  • 16,353
  • 49
  • 133
  • 212
16
votes
2 answers

What content type header to use for JSON? "application/json; charset=utf-8 " or "application/json"?

It seems that the JSON default encoding is UTF-8 and Spring MVC returns application/json; charset=utf-8 by default, which is hard to change.
Bobo
  • 8,777
  • 18
  • 66
  • 85
16
votes
2 answers

How to handle special characters in url as parameter values?

Can anyone suggest how to handle below url as values of parameter of strLocation is haveing special charecters ? Thanks in advance …
Puneet Purohit
  • 1,243
  • 6
  • 23
  • 42
16
votes
3 answers

define two beans of same class in single application context

if I am defining two beans of same class and not giving any scope. Then how many instance of class will get created. for example in applicationContext.xml
S.M.V.A
  • 470
  • 1
  • 5
  • 14
16
votes
2 answers

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven' error

I have added the spring-security-config-3.1.0.RC3.jar in my lib folder and i still get this error. What can be possible reason ?? Here is my dispatcher-servlet.xml
Abhishek Singh
  • 10,243
  • 22
  • 74
  • 108
16
votes
2 answers

How to map Multiple controllers in Spring MVC

I have two controllers in my Application; one is userController, where I have add, delete and update methods; the other one is studentController, where I also have add, delete and update methods. All the mappings are same in my methods using…
AskSharma
  • 187
  • 2
  • 7
  • 15
16
votes
3 answers

Spring MVC set attribute to request/model/modelMap

I use Spring MVC. I need to add attribute to request or other object. It should be message that will display on screen. For example, if I use pure Servlets I may just: request.setAttribute("message", "User deleted"); and than on JSP page
Oleksandr H
  • 2,965
  • 10
  • 40
  • 58
16
votes
1 answer

Spring MockMVC inject mockHttpServletRequest when not in method signature

Given I have inherited some Spring MVC controller code with signature @RequestMapping(value = "/upload", method = RequestMethod.POST) public ModelAndView upload(HttpServletRequest request, HttpServletResponse response) { String remoteAddress =…
Ayub Malik
  • 2,488
  • 6
  • 27
  • 42
16
votes
1 answer

How to implement custom authentication in Spring Security 3?

I know this has been answered so many times, but I am confused. I already have an Authentication mechanism in my application and I just want to use the authorization part of Spring MVC. I'm using Spring MVC 3 and Spring Security 3. When I search on…
user1096311