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

Use Spring Security with JPA

I am new to Spring. We are using spring security feature. Database connectivity: eclipselink implementation of JPA. Database: MySql While using spring security, Configuration of authentication provider is as follows,-
Sagar
  • 1,242
  • 7
  • 22
  • 49
16
votes
3 answers

What template engine should I use in Spring MVC?

I'm learning Spring MVC and want to create a site. The main problem is a template system. Should I use JSP / JSF / Apache FreeMarker / Thymeleaf or something else? I saw a lot of discussion on this subject, but they are all outdated. So, I'm…
Sergey Bakotin
  • 373
  • 1
  • 3
  • 15
16
votes
2 answers

RestTemplate not passing Origin header

I'm trying to make a cross-origin request using Spring's RestTemplate. The communication is done between two Spring-boot webapps, both running on localhost but different port. What I do is: HttpHeaders httpHeaders = new…
Krzysztof Ś
  • 173
  • 1
  • 5
16
votes
2 answers

Spring MVC - Drop Down Object Selection - No primary identifier

A fairly common use case occurs where there is a list of Java objects, from which selections can be made on a web form - usually you'd use the primary key of the object as the value so that the controller could either do a lookup, or just bind the…
walnutmon
  • 5,873
  • 7
  • 42
  • 57
16
votes
2 answers

Thymeleaf classappend for multiple classes

I want to add multiple classes using condition.
I want something like
Vazgen Torosyan
  • 1,255
  • 1
  • 12
  • 26
16
votes
1 answer

Test HTTP status code of redirected URL with MockMvc

I want to test the login process in a Spring Boot Application using MockMvc. After the successful login, the user gets redirected to /home. To test this, I use: @Test public void testLogin() throws Exception { RequestBuilder requestBuilder =…
Ben
  • 1,579
  • 4
  • 20
  • 34
16
votes
4 answers

Can we use multipart and @RequestBody together in spring?

I want to create a API which can have parameter as multipart file and JSON object (@RequestBody). Please find following snippet while calling this API. I am getting HTTP 415 Unsupported Media Type error. If I remove @RequestBody LabPatientInfo…
Mayur
  • 864
  • 6
  • 14
  • 25
16
votes
2 answers

Spring Transaction: What will happen if I don't give @Transaction annotation on method

I am using Spring-Boot, Spring Rest Controller and Spring Data JPA. If I don't specify @Transaction then also record get's created but I will like to understand how it happens.My understanding is that Spring by default adds a transaction with…
JDev
  • 1,662
  • 4
  • 25
  • 55
16
votes
2 answers

Thymeleaf - Button click to call http delete method

I would like to call the url via http delete method. I tried th:onclick and th:action but not working. html code: controller…
richersoon
  • 4,682
  • 13
  • 44
  • 74
16
votes
3 answers

IntelliJ + Spring Web MVC

I have problem with IntelliJ 2016.1.3 and Spring Web MVC integration. Steps I've made: File -> New -> Project... -> Maven (no archetype) GroupId = test ArtifactId = app Project name = App and Finish. I added to pom.xml < packaging > war <…
kmmm
  • 211
  • 1
  • 2
  • 6
16
votes
3 answers

Can we change DispatcherServlet context configuration file name?

In Spring web mvc 1) If we define DispatcherServlet as below appServlet org.springframework.web.servlet.DispatcherServlet it looks for file named…
javanoob
  • 6,070
  • 16
  • 65
  • 88
16
votes
2 answers

Spring Data JPA repository throws null pointer

I've been working with Spring Data with Spring Boot. With the JavaConfig documentation I have set up a Spring JPA configuration, but when calling the save method in my repository a null pointer is thrown. My repository: import…
James Millner
  • 241
  • 2
  • 3
  • 11
16
votes
3 answers

Unable to deserialize Spring Session Scoped bean

I have the following session scoped bean: @ManagedBean @Component @Scope(proxyMode= ScopedProxyMode.TARGET_CLASS, value="session") public class SessionData implements Serializable {} and I store tomcat sessions in a database. The problem is that,…
vtor
  • 8,989
  • 7
  • 51
  • 67
16
votes
2 answers

Spring Swagger UI: what is difference between io.swagger, io.springfox, and com.mangofactory

I am working on integrating the swagger UI with a spring boot MVC app and I am curious as to the differences between these libraries. I looked at each on mvnrepository.com and they are all done by different groups but seem to do the same thing. I…
Sakib
  • 1,503
  • 4
  • 26
  • 39
16
votes
1 answer

Difference between HandlerInterceptor and WebRequestInterceptor?

While writing interceptor for my application I noticed HandlerInterceptor and WebRequestInterceptor here. I noticed that HandlerInterceptor's method take HttpServletRequest, HttpServletResponse, Object(handler) and other params while…
optional
  • 3,260
  • 5
  • 26
  • 47