0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Spring Bootの引数の名前設定について

Posted at

Spring Bootを使い始めて2ヶ月程度の自分がよく目にしてこれなんだっけという自分の記憶定着のために記事を書いていく。

名前の設定

@ModalAttribute@RequestParamsでフロントとデータのやり取りをするが度々どの名前がフロントで使われているのかごっちゃになってしまう。

public void hoge (@ModelAttribute("frontModel") Model serverModel)

例えば上記のようなコードの場合である。常々勉強したり、Springに触れいたりする人はこんな区別当たり前だと思うかもしれないが、初心者はこんなものなのだ。そのため、自分なりに忘れないような覚え方としては、単純に型名をつけて変数名を宣言している方がサーバー側で使う変数となる。

int num = 2;

javaでは、上記のような書き方をするため、それをそのまま応用しているだけと考えればいい。
そのため最初のコードに戻ると、フロント側で使う名前がfrontModelとなり、サーバー側で使う名前がserverModelとなる。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?