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
formtag in thesearch.htmltemplate. (Use@GetMappingor@PostMappingrather than@RequestMapping.) - The
displaySearchResultsmethod should take in aModelparameter. - 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 ajobsArrayList. - Pass
jobsinto thesearch.htmlview via themodelparameter. - Pass
ListController.columnChoicesinto the view, as the existingsearchhandler does.