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

Spring root application context and servlet context confusion

I know that I need to register classes annotated with @Controller in my servlet context to make my webapp accesible. Usually, I will do it the following way: @Configuration @EnableWebMvc @ComponentScan({"foo.bar.controller"}) public class WebConfig…
Oleksii Duzhyi
  • 1,203
  • 3
  • 12
  • 26
17
votes
4 answers

Spring Security ignoring access-denied-handler with Method Level Security

I'm using Spring 3.2.4 and am unable to get Spring Security to redirect to my access-denied-handler when using Annotation based method level security. I have found several different posts about this, but to date, there does not seem to be any…
Eric B.
  • 23,425
  • 50
  • 169
  • 316
17
votes
6 answers

The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template

I am newbie to Spring MVC. I was stuck by an error while running my project Error-The request sent by the client was syntactically incorrect. I have an entity class PatientInfo. My jsp page is demo1. My controller is Patient Controller. The…
north_head
  • 185
  • 1
  • 1
  • 10
17
votes
3 answers

Spring Data @CreatedDate annotation doesn't work for me

I am working on project where I use Spring Data. I wanted to fill in creationTime field using @CreatedDate annotation instead using method with @PreUpdate or @PrePersist annotation (doing it this way it works perfectly). When I do it with…
alicjab
  • 331
  • 2
  • 4
  • 14
17
votes
2 answers

Deferred Result in Spring MVC returning incorrect response

I am using spring mvc 3.2.4 and jquery 1.9.0 for long polling. My application is deployed on Tomcat 7.0.42. My spring configuration files are as below: Application Web.xml
Khalsa_it
  • 231
  • 3
  • 10
17
votes
2 answers

Understanding contexts in Spring MVC

I am new to spring and I am creating a simple web application. I have been reading about contexts in Spring MVC. I am using STS plugin for eclipse. I created a Spring MVC project using the plugin. Now I have three xml documents in the project,…
17
votes
1 answer

Spring and/or Hibernate: Saving many-to-many relations from one side after form submission

The context I have a simple association between two entities - Category and Email (NtoM). I'm trying to create web interface for browsing and managing them. I have a simple e-mail subscription edit form with list of checkboxes that represents…
Rafał Wrzeszcz
  • 1,996
  • 4
  • 23
  • 45
17
votes
2 answers

Returning JsonObject using @ResponseBody in SpringMVC

I am using the new Java API (JSR 353) for JSON in a SpringMVC project. The idea is to generate some piece of Json data and have it returned to the client. The controller I have look somewhat like this: @RequestMapping("/test") @ResponseBody public…
dade
  • 3,340
  • 4
  • 32
  • 53
17
votes
7 answers

WebApplicationContext doesn't autowire

I write this test class : @ContextConfiguration(locations = { "classpath:/test/BeanConfig.xml" }) public class CandidateControllerTest { @Mock(name = "candidateService") private CandidateService candidateService; …
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
17
votes
4 answers

Spring MVC: Url path appending when posting the form

i am new to spring mvc. i created a simple login application. but in my case the first time the for posting url and calling controller method correctly. in second time it's appending path with one more time of controller. first time post: …
manivannan
  • 622
  • 1
  • 4
  • 17
17
votes
3 answers

Spring MVC WebApp : @schedule: java-sdk-http-connection-reaper : Failed to Stop

I have a Web Application(using Spring 3.1) which uses @Scheduled Annotation for periodically executing a worker task (scheduled delay). The worker task opens up a connection to AWS DynamoDb and does some DB read/updates. When I stop the webapp…
agentx
  • 375
  • 2
  • 3
  • 13
17
votes
3 answers

Testing Spring asyncResult() and jsonPath() together

I'm using a restful url to kick off a long-running backend process (it is normally on a cron schedule, but we want the ability to kick it off manually). The code below works and I see the result in the browser when I test…
Matt Byrne
  • 4,908
  • 3
  • 35
  • 52
17
votes
1 answer

Spring MVC controller return HTML

I am having an issue trying when trying to return HTML to my Spring MVC controller. It looks like this: @RequestMapping(value = QUESTION_GROUP_CREATE_URL, method = RequestMethod.POST) public @ResponseBody String createQuestionGroup(@RequestBody…
user2219247
  • 1,313
  • 10
  • 20
  • 26
17
votes
1 answer

Spring Bean Configuration equivalent to

Trying to figure out what the equivalent @Bean configuration would be for the XML element Thanks!
dardo
  • 4,870
  • 4
  • 35
  • 52
17
votes
4 answers

@WebAppConfiguration not injected

I am trying to create spring-mvc tests using Spring 3.2.1. Following some tutorials, I thought this would be straight-forward. Here is my test: @RunWith( SpringJUnit4ClassRunner.class ) @ContextConfiguration( loader =…
sonoerin
  • 5,015
  • 23
  • 75
  • 132