LoginSignup
3
3

More than 5 years have passed since last update.

Thymeleaf リクエストパラメータの文字列比較

Last updated at Posted at 2017-09-12

Thymeleafでリクエストパラメータを使うには${param.hoge}のように書けばいいんですが、th:ifの中で比較しようとするとうまくいかない。

というわけでパラメータ文字列を比較する場合は以下に注意。(公式より引用)

param : リクエストパラメータを取得するために使用します。 ${param.foo} は foo リクエストパラメータの値を持つ String[] です。ですので、最初の値を取得するために普通は${param.foo[0]} を使用します。

つまり

<label th:if="${param.hoge[0].equals('hogehoge')}"></label>

こういうことですね。

参考:
Tutorial: Using Thymeleaf (ja) - 17 Appendix A: Expression Basic Objects - request/session 属性などに対するウェブコンテキストネームスペース

3
3
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
3
3