Reputation: 2698
I am trying to implement an inline search form (if that makes sense). Basically, I want two mappings for this page.
@RequestMapping(value="/application", method=RequestMethod.GET)
public ModelAndView view() {
return new ModelAndView("application");
}
@RequestMapping(value="/application?search=t")
public ModelAndView handleSearch() {
CaseManager caseManager = new CaseManager();
ModelAndView modelAndView = new ModelAndView("application");
modelAndView.addObject("caseList", caseManager.getCaseList());
return modelAndView;
}
So, /application
is the main page of the web app. It has a search bar where a user can enter a handful of search parameters. When they click on search, the table of results should get populated on the page. I went with this route with no luck. I end up getting a 404 on /application?search=t
.
The button's href="WebappName/application?search=t"
Any assistance would be greatly appreciated! I am new to this whole web dev world and got kind of thrown into the fire.
Upvotes: 0
Views: 212
Reputation: 7134
You'll want to use the params
argument to the @RequestMapping
:
e.g.:
@RequestMapping(value="/application" params="search")
If you want to capture the param value and do something with it or
@RequestMapping(value="/application" params="search=t")
if you want to dispatch to a specific param/value combination (looks like the fit in this case).
Upvotes: 3