Reputation: 16117
In my controller i have these ff methods
@RequestMapping("/countryList.html")
@ModelAttribute("countries")
public Collection<Country> getCountries() {
return worldService.getAllCountries();
}
@RequestMapping("/countryList.html")
public String getName() {
return viewers_name;
}
What I was trying to do is that in the countryList.html, it will return the countries and the name of the current user viewing it, however upon accessing the countryList.html it returned me an exception
Ambiguous handler methods mapped for HTTP path '/countryList.html': {public java.lang.String levelup.world.web.CountryController.getName(), public java.util.Collection levelup.world.web.CountryController.getCountries()}.
How would I resolve this issue?
Upvotes: 1
Views: 1334
Reputation: 1613
@RequestMapping("/countryList.html") should be unique to mehod. How you gave this request mapping to two methods.
As Per your comments:-
@RequestMapping(value = "/countryList.html")
public Collection<Country> getCountries(ModelMap model) {
model.addAttribute("countries", countryObject);
return viewName;
}
Or define jsonView in config to return json object for ajax calls
@RequestMapping(value = "/countryList.html")
public Collection<Country> getCountries(ModelMap model) {
model.addAttribute("countries", countryObject);
return jsonView;
}
Upvotes: 2
Reputation: 3141
Because You have the same request mapping to different methods. The exception message is simple
Upvotes: 2