create two method for same url pattern with different arguments
You can use the params
parameter to filter by HTTP parameters. In your case it would be something like:
@RequestMapping(value = "/searchUser", params = "userID")
public String searchUserById(@RequestParam long userID, Model model) {
// ...
}
@RequestMapping(value = "/searchUser", params = "userName")
public ModelAndView searchUserByName(@RequestParam String userName) {
// ...
}