質問編集履歴

1

エラーメッセージ追記、DBの修正

2022/05/07 06:02

投稿

yajiyaji
yajiyaji

スコア1

test CHANGED
File without changes
test CHANGED
@@ -1,12 +1,14 @@
1
1
  【環境】
2
2
  使用言語:JAVA
3
3
  開発環境:Spring Tool Suite、XAMPP(phpMyAdmin)
4
+ DB:MariaDB
4
5
 
5
6
  【前提】
6
7
  Spring Tool Suiteを使用してJAVAのWebアプリを開発しています。
7
8
 
8
9
  LicenseクラスにLocalDate型のフィールド「expiration」が存在し、フォームから入力した値をDBに保存しています。
9
- このDBは、XAMPPのphpMyAdminで管理しています。
10
+ ~~このDBは、XAMPPのphpMyAdminで管理しています。~~
11
+ DBはMariaDBを使用しています。
10
12
 
11
13
  上記expirationを含むテーブルをThymeleafを使用し
12
14
  index.htmlに表示しています。
@@ -57,3 +59,31 @@
57
59
 
58
60
  th:classappendに拘っているわけではないので、違ったアプローチであっても解決方法であったり、調べ方のご助言をいただけると大変助かります。
59
61
  JAVAもThymeleafも素人で、当サイトでの質問も初めてですので、不足している情報がある、聞き方がよくない等ございましたらご指摘ください。
62
+
63
+ 2022/5/7追記
64
+ エラーについて誤り及び追記がございました。
65
+ >th:classappend="${license.expiration lt ('nowDate') ? 'bg-red'"}
66
+ >等と記述してもエラーになります。
67
+ この記述ではエラーになりません。そのかわり、全ての行にクラスが付与され赤くなってしまいます。これは、nowDateが単なる文字列になっているため比較ができていないと理解しています。
68
+
69
+ th:classappend="${license.expiration lt (nowDate) ? 'bg-red'"}
70
+ このように修正した際にエラーが出ていました。
71
+ エラーメッセージを追記します。全文載せると文字数制限を超過するため、「at org.thymeleaf…」等の行は省略しました。
72
+
73
+ ```ここに言語を入力
74
+ エラーメッセージ
75
+ ```Whitelabel Error Page
76
+
77
+ This application has no explicit mapping for /error, so you are seeing this as a fallback.
78
+ Sat May 07 14:39:43 JST 2022
79
+ There was an unexpected error (type=Internal Server Error, status=500).
80
+ An error happened during template parsing (template: "class path resource [templates/index.html]")
81
+ org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")
82
+ (省略)
83
+ Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "license.id lt (nowDate)" (template: "index" - line 58, col 64)
84
+ (省略)
85
+ Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "license.id lt (nowDate)" (template: "index" - line 58, col 64)
86
+ (省略)
87
+ Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1013E: Cannot compare instances of class java.lang.String and class java.util.Date
88
+ (省略)
89
+ Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.String