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

How to pass a session attribute as method argument (parameter) with Spring MVC

In short, I want something like: public String action(@SessionAttribute User user) {..} instead of public String action(HttpSession session) { User user = session.getAttribute("user"); } Mainly for the sake of: readability unit testing
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
15
votes
3 answers

How can I capitalize a string showed by Thymeleaf into a page?

I am working on a Spring MVC application that uses Thymeleaf as template engine and I am trying to capitalize some string showed into my page. On my page I have something like this:
  • AndreaNobili
    • 40,955
    • 107
    • 324
    • 596
  • 15
    votes
    2 answers

    How do I have common error page templates with tiles in a Spring/MVC 3.0 app?

    I have a Spring MVC/3.0 app using tiles as it's view, this is working fine however I can't figure out how to get the error pages to also use tiles. I have in my web.xml 404
    Brett Ryan
    • 26,937
    • 30
    • 128
    • 163
    15
    votes
    3 answers

    What will happen if we interchange @service and @repository annotation in the spring MVC

    Why we needs to use @service inside the service Implementation and @repository in the DAO Implementation. There are no problem occur when I interchange the @service and @repository annotation in the spring MVC.
    Hisoban
    • 153
    • 1
    • 1
    • 7
    15
    votes
    3 answers

    Json schema validation in Spring REST APIs

    I’m building a REST API using Spring Boot and [jackson-module-jsonSchema] (https://github.com/FasterXML/jackson-module-jsonSchema) for JSON schema generation. I’m looking the best way to validate the request JSON payload arriving to my APIs…
    Alec
    • 217
    • 1
    • 3
    • 8
    15
    votes
    4 answers

    What is the equivalent of @Context UriInfo in Spring Rest

    I have worked in Jersey and RESTEasy framework earlier and now we will be using Spring Rest for a new project , I don't want to pass all the query params and matrix params as parameters in the method , and usually I would annotate the method with…
    Vignesh
    • 521
    • 2
    • 6
    • 10
    15
    votes
    1 answer

    Thymeleaf Map Form Binding

    db.html
    On submitting this input, i…
    Abhishek Agarwal
    • 846
    • 4
    • 13
    • 34
    15
    votes
    3 answers

    GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)

    I am very much new to the MOngoDB + Java Configuration. I am trying to achive the connection from remote mongodb server from Java application. I want to use GSSAPI mechanism for connection with mongotemplate. Below code has been executing…
    15
    votes
    3 answers

    How to check request parameter is not empty String in @RequestMapping params?

    In my controller I have String parameter, containing some id, that should not be null of empty string. I'm wondering, is there any way to check it is not empty String in @RequestMapping params? I have tried to solve it in some ways…
    WeGa
    • 801
    • 4
    • 10
    • 24
    15
    votes
    5 answers

    WARNING: Exception encountered during context initialization - cancelling refresh attempt

    Error is as shown below. The problem is, occurring as below, this XmlWebApplicationContext need not occur, since it's injecting the bean again. How to avoid it? org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh INFO:…
    Pavanraotk
    • 1,097
    • 4
    • 15
    • 33
    15
    votes
    4 answers

    Infinite Recursion with Jackson JSON, Spring MVC 4.2 and Hibernate JPA issue

    When Spring MVC try to convert a JPA object that has a bi-directional association into JSON by jackson 2.6.1 , I keep getting org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: Infinite recursion…
    mohammad_1m2
    • 1,571
    • 5
    • 19
    • 38
    15
    votes
    4 answers

    Recommended way to handle Thymeleaf Spring MVC AJAX Forms and their error messages

    What is the recommended way to handle AJAX forms and their error messages on the Thymeleaf side of things? I currently have a Spring controller which returns a JSON overview of fields and their respective error messages, but having to resort to…
    Kristof
    • 1,684
    • 2
    • 23
    • 49
    15
    votes
    1 answer

    Spring Java based configuration with static method

    can any one please advice why we need to declare PropertySourcesPlaceholderConfigurer bean using a static method ? I just found that if I use non-static for below then url will be set to null value instead of taking from property file -…
    Shri S Softwares
    • 1,529
    • 2
    • 12
    • 16
    15
    votes
    1 answer

    How to proxy HTTP requests in Spring MVC?

    I have an application built on top of Spring MVC. I want to write simple proxy that processes requests as follows: send the same HTTP request to some specific server capture HTTP response from this specific server return the same answer to…
    15
    votes
    2 answers

    Spring keeps returning string instead of jsp/html content

    I am trying to understand the whole Spring Framework. To my knowledge, the relatively new techniques of using gradle makes a lot of the tutorials and posts online outdated? The main issue that I am running in to is when I try to display a jsp or…
    JustAName
    • 157
    • 1
    • 1
    • 7
    1 2 3
    99
    100