第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么 th:field 在 Spring View 中不起作用

為什么 th:field 在 Spring View 中不起作用

白衣染霜花 2024-01-28 16:13:48
我正在嘗試創(chuàng)建一個 HTML Web 表單來創(chuàng)建贊助活動(一個模型類),我有一個 Spring 控制器、一個 Thymeleaf 視圖和實體模型。然而,無論我如何嘗試,我似乎都無法讓 th:field 正常工作。我使用此頁面作為參考https://spring.io/guides/gs/handling-form-submission/看法<!DOCTYPE html><html xmlns:th="http://www.thymeleaf.org">  <head>    <title>Create a Sponsored Event</title>  </head>  <body>    <h1>Create a Sponsored Event</h1>    <form action="#" th:action="@{/event/create/submit}" th:object="${sponsor}" method="post">      <input type="text" th:field="*{id}"/> <!-- This Line -->    </form>  </body></html>控制器@Controller@RequestMapping("events")public class SponsorController {  private static final String CREATE_PAGE = "events/create";  @GetMapping("/create")  public String addSponsorEvent(Model model) {    model.addAttribute("sponsor", new Sponsor());    return CREATE_PAGE;  }}模型@Data@Entity@NoArgsConstructor@Accessors(fluent = true)@Table(name = "sponsor_form")public class Sponsor {  @Id  @Column(name = "id")  @GeneratedValue(strategy = GenerationType.IDENTITY)  private int id;}我也嘗試過改變這個<input type="text" th:field="*{id}"/><input type="text" th:field="*{id()}"/><input type="text" th:field="*{sponsor.id}"/><input type="text" th:field="*{sponsor.id()}"/>我收到錯誤:引起原因:org.attoparser.ParseException:執(zhí)行處理器“org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor”期間出錯(模板:“events/create”-第9行,第26欄)
查看完整描述

1 回答

?
開滿天機

TA貢獻1786條經(jīng)驗 獲得超13個贊

在 Model 類 Sponsors 中,錯誤是由 @Accessors( Fluent = true) 引起的,我刪除了這一行并解決了問題。



查看完整回答
反對 回復(fù) 2024-01-28
  • 1 回答
  • 0 關(guān)注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號