concept controller in category spring

This is an excerpt from Manning's book Spring in Action, Sixth Edition.
Spring comes with a powerful web framework known as Spring MVC. At the center of Spring MVC is the concept of a controller, a class that handles requests and responds with information of some sort. In the case of a browser-facing application, a controller responds by optionally populating model data and passing the request on to a view to produce HTML that’s returned to the browser.
Listing 2.6. A controller to present a taco order form
package tacos.web; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import lombok.extern.slf4j.Slf4j; import tacos.TacoOrder; @Slf4j @Controller @RequestMapping("/orders") public class OrderController { @GetMapping("/current") public String orderForm(Model model) { model.addAttribute("tacoOrder", new TacoOrder()); return "orderForm"; } }

This is an excerpt from Manning's book Spring Boot in Action.
Suppose for a moment that the controller is all you need. As it turns out, the Groovy-based controller class shown in listing 1.1 is a complete (even if simple) Spring application.
Table 7.1. Actuator endpoints
HTTP method
Path
Description
GET /autoconfig Provides an auto-configuration report describing what auto-configuration conditions passed and failed. GET /configprops Describes how beans have been injected with configuration properties (including default values). GET /beans Describes all beans in the application context and their relationship to each other. GET /dump Retrieves a snapshot dump of thread activity. GET /env Retrieves all environment properties. GET /env/{name} Retrieves a specific environment value by name. GET /health Reports health metrics for the application, as provided by HealthIndicator implementations. GET /info Retrieves custom information about the application, as provided by any properties prefixed with info. GET /mappings Describes all URI paths and how they’re mapped to controllers (including Actuator endpoints). GET /metrics Reports various application metrics such as memory usage and HTTP request counters. GET /metrics/{name} Reports an individual application metric by name. POST /shutdown Shuts down the application; requires that endpoints.shutdown.enabled be set to true. GET /trace Provides basic trace information (timestamp, headers, and so on) for HTTP requests.
When an application is relatively small, it’s usually easy to know how all of its controllers are mapped to endpoints. But once the web interface exceeds more than a handful of controllers and request-handling methods, it might be helpful to have a list of all of the endpoints exposed by the application.

This is an excerpt from Manning's book Spring in Practice.
Model-view-controller (MVC) refers to the architectural pattern in which you separate your business services and domain objects (the model) from the UI (the view) and mediate their interaction through one or more controllers. You’d like to be able to modify your UI without having to change your business logic and domain objects, and separating the model and view makes it easier to do just that. It’s a simple but proven concept.
Java web applications typically realize MVC in roughly the following way: the model encompasses business-tier code (service beans, POJOs, Enterprise JavaBeans [EJBs], and so forth), the view involves JSPs or similar technologies, and the controller is usually servlet-based. HTTP requests come into the servlet, which routes the request to a handler component (sometimes called an action, sometimes called a controller) that in turn processes the request. The handler makes any necessary calls against the service tier and grabs any domain objects[1] it needs to populate the view. Finally, the handler figures out which view to deliver and forwards processing to that view. Figure 3.1 shows the typical flow.
As indicated, BeanNameUrlHandlerMapping is one of the defaults you get if you don’t specify some other mapping. (If you do specify another mapping, then if you want the BeanNameUrlHandlerMapping you have to define it explicitly, because explicit handler mapping definitions displace the defaults.) It’s very simple. You use the controller bean’s name to specify the handler URLs that map to the controller. Here’s how it works:
<bean name="/contact/*" class="mypackage.MyController"/>The URL is relative to the servlet path. This approach is nice for its simplicity, but it can be verbose if you have a lot of controllers. Let’s see another handler mapping—one that’s concise.
The new form will allow the user to nominate a member for an award. The controller won’t do anything other than show some log output and forward to a “thanks” page. You just want to see how to set up a form. The following listing contains the new form controller.
The new controller is dedicated to serving and processing a form. You define a setter so you can inject a logical view name for a “thanks” page after the user submits a nomination
. It’s probably obvious why you don’t want to return something like /WEB-INF/jsp/nominee/thanks.jsp: that doesn’t give you a good separation between the controller and the view. But it may be less obvious why you don’t return a logical view name, say thanks. You’ll see the answer to that when we discuss the redirect-after-post pattern, but for now take it on faith that even with the view name it often makes sense to keep the controller and view separate.

This is an excerpt from Manning's book Spring Roo in Action.
Controllers—Accept incoming HTTP web requests and return responses, generally using views to present the data.
Controllers wouldn’t be useful without a way to display the data that they place in their models. Let’s take a look at the next component of your web application, the view.
. It’s probably obvious why you don’t want to return something like /WEB-INF/jsp/nominee/thanks.jsp: that doesn’t give you a good separation between the controller and the view. But it may be less obvious why you don’t return a logical view name, say thanks. You’ll see the answer to that when we discuss the redirect-after-post pattern, but for now take it on faith that even with the view name it often makes sense to keep the controller and view separate.