Jpa BindingResult或bean名称的普通目标对象';文件名';作为请求属性“提供”;在尝试更新数据库中的原始数据时,
我在试图更新数据库中的一行时遇到此异常。我在Google上做了很多研究,我发现我应该添加@modelAttribute,这已经完成了 我还发现我需要在@modeldattribute之后添加bindind result,但这也不起作用,所以我删除了它。我使用JPA作为持久性来操作我的数据,spring boot和thymeleaf作为我的视图Jpa BindingResult或bean名称的普通目标对象';文件名';作为请求属性“提供”;在尝试更新数据库中的原始数据时,,jpa,controller,thymeleaf,Jpa,Controller,Thymeleaf,我在试图更新数据库中的一行时遇到此异常。我在Google上做了很多研究,我发现我应该添加@modelAttribute,这已经完成了 我还发现我需要在@modeldattribute之后添加bindind result,但这也不起作用,所以我删除了它。我使用JPA作为持久性来操作我的数据,spring boot和thymeleaf作为我的视图 这些是我的控制器,用于更新和渲染视图 @GetMapping("/edit/{id}") public ModelAnd
@GetMapping("/edit/{id}")
public ModelAndView UpdateList(@PathVariable(name="id") String id) {
ModelAndView mav = new ModelAndView("updateList");
com.pfe.ClientRest.model.Files files = fileServ.get(id);
mav.addObject("Files", files);
return mav ;
}
@PostMapping("/Save")
public String saveRepport(@ModelAttribute("Files") com.pfe.ClientRest.model.Files dbfile) {
fileServ.save(dbfile);
return "/redirect:/ListFile";
}
@Table( name="Files")
@Entity
public class Files {
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Id
private String id;
private String FileName;
private String Verif;
public String getId() {
return id;
}
<div class="container">
<h1> Modifier les informations du Rapports</h1>
<form action="#" th:action="@{/Save}" th:objects="${Files}"
method="post" >
<input type="text" th:field=*{id} readonly="readonly"/>
<input type="text" th:field="*{fileName}" placeholder="Nom du Fichier"
class="form-control mb-4
col-4">
<input type="text" th:field="*{verif}" placeholder="Accepted/Rejected"
class="form-control mb-4
col-4">
<button type="submit" class="btn btn-info col-2"> Mettre à jour</button>
</form>
</div>
修饰符les du融洽信息
梅特雷日
html页面和实体类中的字段名不匹配。这些是区分大小写的。所以正确的答案应该是
private String fileName;
private String verif;
是的,谢谢,但我还是有同样的例外