Web services 百里香叶+;Spring MVC:更新不起作用,更新正在创建新记录
下面是我的控制器类。更新没有发生,每次更新都会创建一条新记录。我正在使用Thymeleaf模板。我做错了吗 SystemConfigController.javaWeb services 百里香叶+;Spring MVC:更新不起作用,更新正在创建新记录,web-services,spring-mvc,spring-boot,thymeleaf,Web Services,Spring Mvc,Spring Boot,Thymeleaf,下面是我的控制器类。更新没有发生,每次更新都会创建一条新记录。我正在使用Thymeleaf模板。我做错了吗 SystemConfigController.java @Controller @RequestMapping("/systemconfig") public class SystemConfigController { @Autowired private SystemConfigService systemConfigService; @RequestMapping(value =
@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/";
}
}检查您的
saveSystemConfig
方法中的systemConfig
是否已设置主键。您的意思是您成功地在DB上创建了新记录,但是在浏览器上看不到它?检查saveSystemConfig
方法中的systemConfig
是否设置了主键。您的意思是成功地在DB上创建了新记录,但在浏览器上看不到它吗?