Thymeleaf + Spring MVC:更新无效,更新正在创建新记录

时间:2017-04-12 14:01:39

标签: web-services spring-mvc spring-boot thymeleaf

以下是我的控制器类。更新未发生,每次更新新记录时都会创建。我正在使用Thymeleaf模板。我做错了吗?

SystemConfigController.java

@Controller
@RequestMapping("/systemconfig")
public class SystemConfigController {

@Autowired
private SystemConfigService systemConfigService;

@RequestMapping(value = "/", method = RequestMethod.GET)
public String findAll(Model model) {
    model.addAttribute("config", systemConfigService.findAll());
    return "systemconfig";
}

@RequestMapping(value = "/save", method = RequestMethod.POST)
public String saveSystemConfig(SystemConfig systemConfig) {
        this.systemConfigService.save(systemConfig);
    return "redirect:/systemconfig/";
}

@RequestMapping("/edit/{id}")
public String editSystemConfig(@PathVariable("id") Integer schemaId, Model model) {
    model.addAttribute("config", this.systemConfigService.findOne(schemaId));
    return "addsystemconfig";
}

@RequestMapping("/view/{id}")
public String viewSystemConfig(@PathVariable("id") Integer schemaId, Model model) {
    model.addAttribute("config", this.systemConfigService.findOne(schemaId));
    return "viewsystemconfig";
}


@RequestMapping("/delete/{id}")
public String delete(@PathVariable("id") Integer schemaId, Model model) {
    this.systemConfigService.delete(schemaId);
    return "redirect:/systemconfig/";
}

}

0 个答案:

没有答案