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
1 answer

ClassNotFoundException FreeMarkerConfigurationFactory

I have a big web application that uses FreeMarker. When I recently updated to Spring 3.2.4 and ran the web app via jetty or tomcat I get the following exception: java.lang.ClassNotFoundException: …
Millad
  • 1,535
  • 1
  • 16
  • 17
16
votes
4 answers

'Application context not configured for this file' error after moving and renaming the default application-config.xml of IntelliJ IDEA

I have created a Spring Mvc application using IntelliJ IDEA and then I moved and renamed the default application-config file to another directory. Now I am getting this error : 'Application context not configured for this file' The new place of the…
skiabox
  • 3,449
  • 12
  • 63
  • 95
16
votes
2 answers

java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException

I am trying to create a simple project using Spring MVC+JPA Hibernate+maven. My web.xml is as follows ContactManager org.springframework.web.servlet.DispatcherServlet
Sandhya
  • 209
  • 1
  • 4
  • 6
16
votes
4 answers

Passing BindingResult through RedirectionAttributes

I am stuck trying to passing the BindingResult through RedirectionAttributes: I have referenced Spring - Redirect after POST (even with validation errors), but am still stuck. I have a GET method: @RequestMapping(value = "/test", method =…
jared
  • 337
  • 1
  • 2
  • 9
16
votes
4 answers

Spring - Intercepting bean creation and injecting custom proxy

I have a @Controller with @Autowired fields and handler methods that I want to annotate with custom annotations. For example, @Controller public class MyController{ @Autowired public MyDao myDao; @RequestMapping("/home") …
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
16
votes
4 answers

Accessing scoped proxy beans within Threads of

I have a web application running in tomcat where I'm using a ThreadPool (Java 5 ExecutorService) to run IO intensive operations in parallel to improve performance. I would like to have some of the beans used within each pooled thread be in the…
Perulish8
  • 223
  • 1
  • 2
  • 7
16
votes
4 answers

Performing a redirect from a spring MVC @ExceptionHandler method

I want to have the following method: @ExceptionHandler(MyRuntimeException.class) public String myRuntimeException(MyRuntimeException e, RedirectAttributes redirectAttrs){//does not work redirectAttrs.addFlashAttribute("error", e); return…
balteo
  • 23,602
  • 63
  • 219
  • 412
16
votes
3 answers

Maintaining Clean Architecture in Spring MVC with a data-centric approach

Maintaining Clean Architecture in Spring MVC with a data-centric approach I'm trying to map out the architecture for the front-end of a new Java-based web app (portal type application) we are making at work. I want to get this right from day one,…
16
votes
4 answers

How can I get the autoincremented id when I insert a record in a table via jdbctemplate

private void insertIntoMyTable (Myclass m) { String query = "INSERT INTO MYTABLE (NAME) VALUES (?)"; jdbcTemplate.update(query, m.getName()); } When the above query inserts a record, the ID column in the table autoincrements. Is there a…
birdy
  • 9,286
  • 24
  • 107
  • 171
16
votes
2 answers

IP filter using Spring Security

I wonder how to filter users' access to my web app by their IP using Spring Security. Should I extend AbstractAuthenticationProcessingFilter or something like that and override it's methods in my own way? If so, could you give an example of such…
16
votes
3 answers

RestTemplate post for entity

My post method gets called but my Profile is empty. What is wrong with this approach? Must I use @Requestbody to use the RestTemplate? Profile profile = new Profile(); profile.setEmail(email); String response =…
pethel
  • 5,397
  • 12
  • 55
  • 86
16
votes
3 answers

How do I get Spring MVC to invoke validation in a JUnit test?

I have a POJO called Browser that I've annotated with Hibernate Validator annotations. import org.hibernate.validator.constraints.NotEmpty; public class Browser { @NotEmpty private String userAgent; @NotEmpty private String…
Matt Raible
  • 8,187
  • 9
  • 61
  • 120
16
votes
2 answers

ServletDispatcher cannot be cast to Javax.servlet.Servlet exception in my spring project

While starting tomcat server I am getting an exception SEVERE: Servlet /MavenWeb threw load() exception java.lang.ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet I am using spring3 but…
Manth
  • 358
  • 3
  • 4
  • 14
16
votes
5 answers

Class cannot be cast to java.lang.reflect.ParameterizedType

Currently the VariableService is @Autowired in my controller. I realize I can implement the class ParameterizedType to make this error go away but I fear that I may be headed in the wrong direction. Is there a better way to do this or do I need to…
Ben
  • 60,438
  • 111
  • 314
  • 488
16
votes
3 answers

What is difference between class path , file system?

I know that: ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml"); loads context definition from an XML file located in the classpath, treating context definitions as classpath resources. ApplicationContext context = new…
Sachin J
  • 2,081
  • 12
  • 36
  • 50