From the course: Complete Guide to Spring MVC
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Controllers and views - Spring Tutorial
From the course: Complete Guide to Spring MVC
Controllers and views
- [Instructor] Controllers and Views. View controllers and view resolvers are used to simplify the process of mapping requests to views and resolving them to specific technologies such as the JSP, the Thymeleaf, or FreeMarker. Let's look at how these components work together to enhance your application's view resolution and content delivery. A view controller maps a request directly to a view without involving any Java logic or controller method. They're typically used for static content that doesn't require any business logic. In this example of a view controller, I'm using Java configuration to configure a view controller that implements the WebMVCConfigurer interface and override the addViewControllers method. View controllers are best for static pages. When a page requires dynamic content or logic, using a controller is a better choice. Avoid mapping the same URL to both a view controller and a controller that has request mapping annotation as spring MVC will prioritize the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.