Ch10: Controllers and Routing Flashcards
Define request
In exchange of data between client and server, the client sends the request to a specific URL
Define response
In the exchange of data between client and server, the response is a message returned by the server
@Controller
Annotation designating given class as a controller
@GetMapping(“pathname”)
Designates controller action. If GET request made to this path, the method will be called
Use a ____ annotation any time controller needs to respond to requests
Mapping
@RequestMapping
Can handle more than one method (ex: GET and POST). Can be applied at class level to designate base path for all methods in class
It’s a best practice to place all controller classes in their own _____
subpackage (note: pkgs are lowercase in Java)
Why are routes important?
Help determine which requests get sent to which controller
Define query string
Extro info included at end of URL (key=value&key=value)
Dynamic vs Static response
Static - requests to same path will always return the same response.
Dynamic - response will change based on data sent in the request
@RequestParam
Annotation used before argument in a controller method. Lets handler method know to look for a query string
@PathVariable
Annotation used before argument in a controller method. Lets handler method know to look for a path variable
Describe how you would redirect a user
Remove @ResponseBody annotation (if any) and return redirect:/DESIREDPATH
How does action function in the following form tag?
”
Action specifies the path the form will be submitted at
What is the default method of a form tag
GET