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

Spring 3 Security: AccessDeniedHandler is not being invoked

I have a spring 3 application with the configurations given below. When any user tries to access a page and he/she isn't logged in, I get an Access is Denied exception with an ugly stack trace. How do I handle this exception and not let it dump out…
Ritesh M Nayak
  • 8,001
  • 14
  • 49
  • 78
16
votes
1 answer

$proxy25 error with Spring Service

I have two Service classes which implement the same interface ServiceClass1 @Service public class ServiceClass1 implements ItemsService{ @Autowired Class1DaoImpl class1Dao; @Transactional public List getAllItems() { return…
RKodakandla
  • 3,318
  • 13
  • 59
  • 79
16
votes
4 answers

Environment-specific configuration for a Spring-based web application?

How can I know the deployment environment of a web application, e.g. whether it is local, dev, qa or prod, etc. Is there any way I can determine this in spring application context file at runtime?
Ritesh Mengji
  • 6,000
  • 9
  • 30
  • 46
16
votes
2 answers

Spring Boot RestController, On Error Status Response Body, Message of Error is empty

On my Spring Boot RestController I want to pass a custom error message to the response body by throwing a custom exception. I was following the guide on https://dzone.com/articles/spring-rest-service-exception-handling-1 These are my code…
Hannes Roth
  • 163
  • 1
  • 1
  • 7
16
votes
2 answers

Set session variable spring mvc 3

How can I set a session object which I can use then in any of my views by using ${variable} or ${requestScope.variable} To be able to use sessions do I need to set <%@ page session="true" %> ?
Gandalf StormCrow
  • 25,788
  • 70
  • 174
  • 263
16
votes
5 answers

@Autowired object gets a null value in one class, while successfully wired in another

I am working on a project using Spring 3, and Spring Security. My problem is with IoC container. Problem started when I wrote my own implementation of UserDetailsService for Spring Security-3. I checked the other questions but still could not solve…
Ugur Adigüzel
  • 203
  • 1
  • 2
  • 13
16
votes
2 answers

Spring boot - Pass argument from interceptor to method in controller

For learning purposes, I have made a custom authentication system where I pass a token from the client to the server through the Authorization header. In the server side, I'd like to know if it's possible to create in the interceptor, before the…
Ulises CT
  • 1,361
  • 1
  • 12
  • 21
16
votes
8 answers

Spring/Hibernate @Transactional - Session closing before it should

I can't figure out why, but the Hibernate session is closing before it should, so I can't fetch lazily loaded lists. In the logs, it's showing that the session closes immediately after hibernateTemplate.findByNamedParam() inside the DAO. When I run…
Corey
  • 1,133
  • 4
  • 17
  • 30
16
votes
1 answer

How to implement Long Polling REST endpoint in Spring Boot app?

Would you be so kind as to share any up-to-date manual or explain here how to implement a REST Long Polling endpoint with the latest Spring (Spring Boot)? Everything that I've found by this time is quite out-dated and was issued a couple of years…
Pasha
  • 1,768
  • 6
  • 22
  • 43
16
votes
3 answers

How to set properly the loader path of velocity

i would like that my velocityengine look for templates from a designed path. i did this :
storm_buster
  • 7,362
  • 18
  • 53
  • 75
16
votes
4 answers

Constructor injection on abstract class and children

I have a class as follows @Component public abstract class NotificationCenter { protected final EmailService emailService; protected final Logger log = LoggerFactory.getLogger(getClass()); protected NotificationCenter(EmailService…
prettyvoid
  • 3,446
  • 6
  • 36
  • 60
16
votes
4 answers

Spring MVC Controller Design

We are migrating a struts application over to Spring MVC and utilizing the @Controller annotation to direct pages to various method calls. I'm having trouble determining a good strategy for reuse though. We basically do the same things in many of…
Scott
  • 9,458
  • 7
  • 54
  • 81
16
votes
2 answers

Can spring map POST parameters by a way other than @RequestBody

I am using @RestControllers with an application where all requests are POST requests ... As I learned from this post , you can't map individual post parameters to individual method arguments, rather you need to wrap all the parameters in an object…
osama yaccoub
  • 1,884
  • 2
  • 17
  • 47
16
votes
3 answers

Spring MVC validation with Annotations

I'm having quite some trouble since I migrated my controllers from classical inheritance to use the annotations like @Controller and @RequestMapping. The problem is that I don't know how to plug in validation like in the old case. Are there any good…
cdecker
  • 4,515
  • 8
  • 46
  • 75
16
votes
1 answer

Casting from HttpServletRequest to WebRequest

I've generated a Spring Boot web application using Spring Initializer, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file. Technologies used: Spring Boot 2.0.0.M6 , Java 8, maven I have this method in 1 of the…
en Lopes
  • 1,863
  • 11
  • 48
  • 90