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

Receiving error Failed to invoke @ExceptionHandler even with a custom @ControllerAdvice defined

I have an app with Spring 4.1.6 where I created a class for handling all exceptions as follow: @ControllerAdvice public class RestControllerAdvice { ... @ExceptionHandler({Exception.class}) public ResponseEntity handleException(final…
dambros
  • 4,252
  • 1
  • 23
  • 39
15
votes
2 answers

Difference between spring mvc and Jersey

Is there any trade off between using Spring mvc and Jersey Rest servlet container ? Jersey follows Jax RS standard. When I learn Spring mvc, more or less looks the same. In some applications I found people use jersey spring servlet. If spring…
Muthu
  • 540
  • 2
  • 5
  • 18
15
votes
2 answers

How to get the exact client browser name and version in Spring MVC?

I'm working on a Spring MVC application, and I need to access client browser name and version. I have an instance of HttpServletRequest in my action as a parameter and use request.getHeader("User-Agent") method, but this returned Mozilla/5.0…
hamed
  • 7,939
  • 15
  • 60
  • 114
15
votes
4 answers

Spring Boot Deployed in Tomcat gives 404 but works Stand-alone

I have been testing Spring Boot with embedded Tomcat for about a month now to build a REST API. Everything was working fine. We now want to deploy the API in a separate development environment which has a couple of other (non-Spring) applications…
xelamitchell
  • 522
  • 1
  • 6
  • 18
15
votes
5 answers

Passing List of Integers to GET REST API

I wanted to fetch the List of Entities from database at Front end. So I have written POST REST HTTP call in Spring MVC. But I read the HTTP documentation which says whenever you have to retrieve data from database prefer GET call. So, Is it there…
virsha
  • 1,140
  • 4
  • 19
  • 40
15
votes
1 answer

Spring MVC how to forbid data binding to ModelAttribute?

I have a simple @Controller class that renders a page after user has logged in: @Controller @SessionAttributes("user") public class DashBoardController { @RequestMapping(value="/user/dashBoard", method=RequestMethod.GET) public String…
troy
  • 704
  • 8
  • 16
15
votes
2 answers

Using JPA entity graph with complex conditions

I have a project built on Spring MVC + JPA + Hibernate. I am using entity graphs (JPA 2.1) for defining which data to fetch from the database, like in the example below. EntityGraph entityGraph =…
ba0708
  • 10,180
  • 13
  • 67
  • 99
15
votes
2 answers

The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped

I've seen few similar issues on stackoverflow but i could not figure out how i can solve my problem. After adding Spring Security to my Spring MVC project i got following exception: Jul 20, 2014 3:18:04 PM…
user3127896
  • 6,323
  • 15
  • 39
  • 65
15
votes
5 answers

Are there any examples/tutorials of using Spring 3.0 with Cassandra as a backend?

As I had written in title, I am trying to learn Spring 3.0 (I already know Django, Pylons and few simpler MVC frameworks) and try to use Cassandra as a backend for my web application. Are there any real world examples of doing this? Or maybe some…
zeroDivisible
  • 4,041
  • 8
  • 40
  • 62
15
votes
2 answers

Spring RestTemplate - Overriding ResponseErrorHandler

I am calling a ReST service through RestTemplate and trying to override ResponseErrorHandler in Spring 3.2 to handle custom error codes. CustomResponseErrroHandler public class MyResponseErrorHandler implements ResponseErrorHandler { @Override …
user3670450
  • 151
  • 1
  • 1
  • 4
15
votes
5 answers

Spring MVC - allowing requests from localhost only to specific controller

I have a specific controller (among many other controllers). I would like to allow requests to this controller that are being invoked from localhost only. Whats the best way to do this? here is the controller: @Controller public class LocalProvider…
Urbanleg
  • 6,252
  • 16
  • 76
  • 139
15
votes
2 answers

Inject HttpServletRequest into Controller

As I know per default are controllers in Spring MVC singletons. HttpServletRequest passed offen to the controller handler method. And its ok, while HttpServletRequest is request-scoped, but I see often HttpServletRequest gets @Autowired into the…
speechkey
  • 625
  • 2
  • 10
  • 16
15
votes
6 answers

Accessing Spring MVC DI beans from jsp

In some MVC frameworks you can call controller action from the view if you wish to execute some code and render some partial view. I'm not sure what is the correct way to do it in Spring MVC I want to have set of JSP templates. Some of them will be…
Art79
  • 313
  • 2
  • 5
  • 16
15
votes
3 answers

Bind UUID in Spring MVC

What is the easiest way to bind a UUID in Spring MVC, such that this works: @RequestMapping("/MyController.myAction.mvc") @ResponseBody public String myAction(UUID id, String myParam)... Using the above I currentely get the following…
Kong
  • 8,792
  • 15
  • 68
  • 98
15
votes
3 answers

Which return type use in spring mvc in @RequestMapping method?

I know in spring mvc in @Controller class in @RequestMapping method I can return String Model ModelAndView I don't understand differencies between these actions. Can you to explain me it?
user2740224
1 2 3
99
100