【发布时间】:2019-09-03 23:22:05
【问题描述】:
我该如何处理这个异常
这是为了从 JPA 持久性中捕获错误
try {
if (platform.getPlatformId() == null) {
messageString = "inserted";
} else {
messageString = "updated";
}
Platform platf = platformServiceImpl.addOne(platform);
model.addAttribute("locations", locationServiceImpl.getAll());
//Date localDate = new Date();
//PlatformDetail newDetailPlatform = new PlatformDetail();
//newDetailPlatform.setLastUpdate(localDate);
//newDetailPlatform.setPlatform(platform);
//platformDetailServiceImpl.addOne(newDetailPlatform);
//redirectAttributes.addAttribute("platformId", platf.getPlatformId());
redirectAttributes.addFlashAttribute("success", messageString);
return "redirect:/admin/step1/" + platf.getPlatformId();
} catch (PersistenceException ex) {
redirectAttributes.addFlashAttribute("error", "dfdf");
return "redirect:/admin/step1/" + ex.getCause();
}
我希望发送带有重复键的 RedirectParameter 并显示为消息
【问题讨论】:
标签: java spring-boot