如何在没有任何更改的情况下更新值时防止重复验证?

时间:2017-02-17 05:18:50

标签: spring-mvc

@RequestMapping(value = "/updateYearMaster", method = RequestMethod.POST)
public String updateYearmaster(@RequestParam(value = "id", required = false) Long id,
                               @RequestParam(value = "fromyear", required = false) Date fromyear,
                               @RequestParam(value = "toyear", required = false) Date toyear,
                               @RequestParam(value = "status", required = false) String status,
                               @RequestParam(value = "yeardescription", required = false) String yeardescription, Model model) {
    Yearmaster yearmaster = new Yearmaster(fromyear, toyear, status, yeardescription);
    yearmaster.setId(id);
    List val = yearmasterService.duplicateEditYear(fromyear, toyear, id);
    if (!val.isEmpty()) {
        model.addAttribute("yearmaster", yearmaster);
        errorMessage = "fromyear and toyear combination is already exist";
        model.addAttribute("errorMessage", errorMessage);
        return "edit-year-master";

    } else {
        yearmasterService.save(yearmaster);
        return "redirect:/yearmaster";
    }
}

0 个答案:

没有答案