I am working on a Spring mvc application in which I have to display a list of locations. I have a controller method for location. Following is my controller method code:
@RequestMapping("/location")
public class LocationController {
@RequestMapping(value = "/home")
public String showAllLocations(ModelMap modelMap) {
logger.info("showAllLocations() begins:");
try {
List<LocationModel> locationList = locationService
.getAllLocations("");
modelMap.addAttribute("locationlist", locationList);
} catch (Exception e) {
logger.debug("Error while getting locations: " + e.getMessage());
e.printStackTrace();
}
return "LocationHome";
}
}
It works fine when I user following URL:
http://www.example.com:8080/myapp/location/home
But when I use http://www.example.com:8080/myapp/location, it shows error.
How can I view location list without using 'home', by following URL:
@RequestMapping(value = "")