Task 3: Complete SearchController
Add a displaySearchResults
handler method to SearchController
:
- Use the correct annotation for the method. To configure the correct mapping
type and mapping route, refer to the
form
tag in thesearch.html
template. (Use@GetMapping
or@PostMapping
rather than@RequestMapping
.) - The
displaySearchResults
method should take in aModel
parameter. - The method should also take in two other parameters, specifying the type of search and the search term.
- In order for these last two parameters to be properly passed in by Spring
Boot, you need to use the correct annotation. Also, you need to name them
appropriately, based on the corresponding form field names defined in
search.html
. - If the user enters “all” in the search box, or if they leave the box empty,
call the
findAll()
method fromJobData
. Otherwise, send the search information tofindByColumnAndValue
. In either case, store the results in ajobs
ArrayList. - Pass
jobs
into thesearch.html
view via themodel
parameter. - Pass
ListController.columnChoices
into the view, as the existingsearch
handler does.