前提・実現したいこと
SpringBootでDBのデータを取得してthymeleafで表示させたいのですが、受け渡しにエラーが出てしまい困っています。解決方法をご教授いただければ幸いです。
発生している問題・エラーメッセージ
There was an unexpected error (type=Internal Server Error, status=500). An error happened during template parsing (template: "class path resource [templates/visitorPC/visitor-sheet-top.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/visitorPC/visitor-sheet-top.html]") 略 Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "list.visitDatetime" (template: "visitorPC/visitor-sheet-top" - line 158, col 37) 略 Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "list.visitDatetime" (template: "visitorPC/visitor-sheet-top" - line 158, col 37) 略 Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'visitDatetime' cannot be found on null
該当のthymeleaf
<table id="example" class="table table-striped table-bordered nowrap" style="width:100%"> <thead th:each="list : ${velist}"> <tr> <th>訪問日</th> <th>会社名</th> <th>訪問者名</th> <th>人数</th> <th>ご用件</th> <th>面会者/立会人</th> <th>退出時刻</th> <th>編集</th> </tr> </thead> <tbody> <tr> <td th:text=${list.visitDatetime}></td> <td th:text=${list.company_name}></td> <td th:text=${list.visitor_name}></td> <td th:text=${list.visitor_number}></td> <td th:text=${list.requirements}></td> <td th:text=${list.personal_id}></td> </tr> </tbody> </table>
該当のController
@RequestMapping(value = "/web-visitor/top", method = RequestMethod.GET) public ModelAndView getInfoTop(ModelAndView mav) { mav.setViewName("visitorPC/visitor-sheet-top"); Iterable<VisitorRecordEntity> velist = vrep.findVisitorRecordByDeleteFlag(); mav.addObject("velist", velist); return mav; }
該当のEntity
@Entity @Table(name = "t_visitor_records") public class VisitorRecordEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "visit_no") private Long id; @Column(name = "visit_datetime") private String visitDatetime; @Column private String company_name; @Column private String visitor_name; @Column private int visitor_number; @Column private String requirements; @Column private int personal_id; @Column(name = "leave_time") private String leaveTime; @Column private int register_id; @Column private String register_date; @Column private int editor_id; @Column private String edit_date; @Column private int delete_flag; @Column private String delete_date; @Column(name = "deleter_id") private int delete_id; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getVisitDatetime() { return visitDatetime; } public void setVisitDatetime(String visitDatetime) { this.visitDatetime = visitDatetime; } public String getCompany_name() { return company_name; } public void setCompany_name(String company_name) { this.company_name = company_name; } public String getVisitor_name() { return visitor_name; } public void setVisitor_name(String visitor_name) { this.visitor_name = visitor_name; } public int getVisitor_number() { return visitor_number; } public void setVisitor_number(int visitor_number) { this.visitor_number = visitor_number; } public String getRequirements() { return requirements; } public void setRequirements(String requirements) { this.requirements = requirements; } public int getPersonal_id() { return personal_id; } public void setPersonal_id(int personal_id) { this.personal_id = personal_id; } public String getLeaveTime() { return leaveTime; } public void setLeaveTime(String leaveTime) { this.leaveTime = leaveTime; } public int getResister_id() { return register_id; } public void setResister_id(int resister_id) { this.register_id = resister_id; } public String getResisiter_date() { return register_date; } public void setResisiter_date(String resisiter_date) { this.register_date = resisiter_date; } public int getEditor_id() { return editor_id; } public void setEditor_id(int editor_id) { this.editor_id = editor_id; } public String getEdit_date() { return edit_date; } public void setEdit_date(String edit_date) { this.edit_date = edit_date; } public int getDelete_flag() { return delete_flag; } public void setDelete_flag(int delete_flag) { this.delete_flag = delete_flag; } public String getDelete_date() { return delete_date; } public void setDelete_date(String delete_date) { this.delete_date = delete_date; } public int getDelete_id() { return delete_id; } public void setDelete_id(int delete_id) { this.delete_id = delete_id; } }
試したこと
デバッグを行い、DBからデータを取得して、Entityのリストに入っていることは確認できました。EL式の記述方法も確認しているのですが、原因がわかりません。
お願いいたします。
htmlのline 158, col 37 を見ればわかることもあるかと思いますが、そこは見られてますか?
回答2件
あなたの回答
tips
プレビュー