0
0

More than 1 year has passed since last update.

Springの備忘録

Posted at

※SpringBootの学習での知識を備忘録として記載しています。

  • Inputタグの値の受け渡しについて
    Inputタグ(textやhidden)に設定してある値がサーバで受け取れない事象があり、
    調べるとth:filedやth:nameに値が入っているとth:valueが空になるらしい...

    実際に試したところ、th:nameが入っているとたしかにth:valueの値がNullになっているが、th:filedは入っていても問題なさそう

    また、Form内に定義しているクラス内のクラス変数に値を設定したい場合は以下で設定が可能
    InputタグのnameにFormクラスに定義しているTestクラスの変数名.Testクラスの変数名

java
  public class From {
    // Testクラスを定義
    private Test test;
  }

  public class Test {
    // TestクラスでtestIdを定義
    private String testId;
  }
HTML
<form th:object="${form}">
  <Input type="text" th:value="*{test.testId}" name="test.testId">

・参考
親バカエンジニアのナレッジ帳

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0