Andrew Golovko
@andrewgolovko
Blog of a self-taught programmer writing about the experience, tips and other stuff
153 posts
Spring MVC and Web Layer

M05 Q11 What are some of the valid return types of a controller method?

M05 Q10 What other annotations might you use on a controller method parameter?

M05 Q09 What are some of the parameter types for a controller method?

Spring Framework supports many parameter types for controllers.

M05 Q08 What are the differences between @RequestParam and @PathVariable?

The main difference between @RequestParam and @PathVariable is a purpose of each annotation.

M05 Q07 What is @RequestParam used for?

@RequestParam is used to bind web request parameters to controller method parameter.

M05 Q06 What is the difference between @RequestMapping and @GetMapping?

The main difference between @RequestMapping and @GetMapping is that the first one can be used to map any HTTP method requests and the second one can be used to map only HTTP GET method requests. @GetMapping is less flexible but easier to use

M05 Q05 How is an incoming request mapped to a controller and mapped to a method?

Incoming request is mapped to a controller and a method by DispatcherServlet, which uses HandlerMapping and HandlerAdapter components for this purpose.

M05 Q04 What is the @Controller annotation used for?

@Controller annotation is used to indicate that annotated class is a Controller from Model-View-Controller Design Pattern, and should be considered a candidate for request handling when DispatcherServlet searches for component to which work can be delegated.

M05 Q03 What is a web application context? What extra scopes does it offer?

Web Application Context is a Spring Application Context for Web Applications that runs under Embedded or Standalone Application Server that supports Servlet API and acts as Servlet Container.

M05 Q02 What is the DispatcherServlet and what is it used for?

DispatcherServlet is an internal Spring MVC component that implements HttpServlet from Java Servlet API and Front Controller Design Pattern. It is used to handle all requests to the application, based on servlet mapping, delegate those requests to controllers and produce response based on identified view.