I have a view that is rendered with this method:
@RequestMapping("/employee/{id}")
public String showSpecificEmployee(@PathVariable String id, Model model){
model.addAttribute("employee", employeeService.findEmployeeById(new Long(id)));
DateCommand dateCommand = new DateCommand();
dateCommand.setEmployeeId(new Long(id));
model.addAttribute("date", dateCommand);
return "specificEmployee";
}
The view displayes some basic information about the Employee
. On the same view, I do have a form to choose a month and filter the information by Date
.
After the Date
is chosen, I would like to have the view 'refreshed' with updated information. That means I do have a POST & GET methods bound to the same view.
@RequestMapping("/passdate")
public String updateWorkmonth(@ModelAttribute DateCommand dateCommand, Model model){
model.addAttribute("employee", employeeService.findEmployeeWithFilteredWorkdaysAndPayments(dateCommand.getEmployeeId(), dateCommand.getActualDate()));
model.addAttribute("date", dateCommand);
return "specificEmployee";
}
After the second method is invoked looks like
http://localhost:8080/passdate?employeeId=1&actualDate=2018-02
, but I want it to be /employee/{id}
. How do I combine those 2 methods, so they point to the same URL?
If I set @RequestMapping("/employee/{id}")
on both methods, I keep getting an error.