質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

Q&A

解決済

1回答

274閲覧

spring boot TemplateInputException

aaa11

総合スコア14

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

0グッド

0クリップ

投稿2021/02/24 12:57

編集2021/02/24 13:01
registForm.htmlから値を送信してregistConfirm.htmlに値を表示したいのですがエラーが出ていて registConfirm.htmlが表示されません。わかる方いたら教えてください。 There was an unexpected error (type=Internal Server Error, status=500). An error happened during template parsing (template: "class path resource [templates/registConfirm.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/registConfirm.html]") at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666) at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366) at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190) 一部抜粋したエラーのメッセージになります。

Controller

1@Controller 2@RequestMapping("/regist") 3public class EmployeeManagementController { 4 5 @GetMapping("/form") 6 public String registForm(EmployeeFormData employeeFormData) { 7 return "registForm"; 8 } 9 10 @PostMapping("/form") 11 public String registFormBack(EmployeeFormData employeeFormData) { 12 return "registForm"; 13 } 14 15 @PostMapping("/confirm") 16 public String confirm(@Validated EmployeeFormData employeeFormData,BindingResult result) { 17 if(result.hasErrors()) { 18 return "registForm"; 19 } 20 return "registConfirm"; 21 }

EmployeeFormData

1@Data 2public class EmployeeFormData { 3 4 EmployeeFormData() {} 5 6 @NotBlank 7 @Size(min = 4 , max = 8) 8 private String employeeId; 9 10 @NotBlank 11 private String employee_firstName; 12 13 @NotBlank 14 private String employee_firstName_kana; 15 16 @NotBlank 17 private String employee_lastName; 18 19 @NotBlank 20 private String employee_lastName_kana; 21 22 @NotBlank 23 private String sex; 24 25 @NotBlank 26 private String birthday; 27 28 @NotBlank 29 private String age; 30 31 @NotBlank 32 private String cellhone; 33 34 @NotBlank 35 private String addressNomber; 36 37 @NotBlank 38 private String address01; 39 40 @NotBlank 41 private String address02; 42} 43

registFormhtml

1<!DOCTYPE html> 2<html xmlns:th ="http://www.thymeleaf.org"> 3<head> 4<meta charset="UTF-8"> 5<title>Insert title here</title> 6</head> 7<body> 8<form method="post" action="#" th:action="@{/regist/confirm}" th:object="${employeeFormData}"> 9 10 <label for="employeeId">社員ID:</label> 11 <input id="employeeId" name="employeeId" type="text" th:value = "*{employeeId}"><br> 12 <div th:if="${#fields.hasErrors('employeeId')}" th:errors="*{employeeId}"></div> 13 14 <label for="employee_firstName">氏:</label> 15 <input id="employee_firstName" name="employee_firstName" type="text" th:value = "*{employee_firstName}"><br> 16 <div th:if="${#fields.hasErrors('employee_firstName')}" th:errors="*{employee_firstName}"></div> 17 18 <label for="employee_firstName_kana">氏(ふりがな):</label> 19 <input id="employee_firstName_kana" name="employee_firstName_kana" type="text" th:value = "*{employee_firstName_kana}"><br> 20 <div th:if="${#fields.hasErrors('employee_firstName_kana')}" th:errors="*{employee_firstName_kana}"></div> 21 22 <label for="employee_lastName">名:</label> 23 <input id="employee_lastName" name="employee_lastName" type="text" th:value = "*{employee_lastName}"><br> 24 <div th:if="${#fields.hasErrors('employee_lastName')}" th:errors="*{employee_lastName}"></div> 25 26 <label for="employee_lastName_kana">名(ふりがな):</label> 27 <input id="employee_lastName_kana" name="employee_lastName_kana" type="text" th:value = "*{employee_lastName_kana}"><br> 28 <div th:if="${#fields.hasErrors('employee_lastName_kana')}" th:errors="*{employee_lastName_kana}"></div> 29 30 <label for="sex">性別:</label> 31 <input id="sex" name="sex" type="text" th:value = "*{sex}"><br> 32 <div th:if="${#fields.hasErrors('sex')}" th:errors="*{sex}"></div> 33 34 <label for="birthday">生年月日:</label> 35 <input id="birthday" name="birthday" type="text" th:value = "*{birthday}"><br> 36 <div th:if="${#fields.hasErrors('birthday')}" th:errors="*{birthday}"></div> 37 38 <label for="age">年齢:</label> 39 <input id="age" name="age" type="text" th:value = "*{age}"><br> 40 <div th:if="${#fields.hasErrors('age')}" th:errors="*{age}"></div> 41 42 <label for="cellhone">電話番号:</label> 43 <input id="cellhone" name="cellhone" type="text" th:value = "*{cellhone}"><br> 44 <div th:if="${#fields.hasErrors('cellhone')}" th:errors="*{cellhone}"></div> 45 46 <label for="addressNomber">郵便番号:</label> 47 <input id="addressNomber" name="addressNomber" type="text" th:value = "*{addressNomber}"><br> 48 <div th:if="${#fields.hasErrors('addressNomber')}" th:errors="*{addressNomber}"></div> 49 50 <label for="address01">都道府県:</label> 51 <input id="address01" name="address01" type="text" th:value = "*{address01}"><br> 52 <div th:if="${#fields.hasErrors('address01')}" th:errors="*{address01}"></div> 53 54 <label for="address02">市町村:</label> 55 <input id="address02" name="address02" type="text" th:value = "*{address02}"><br> 56 <div th:if="${#fields.hasErrors('address02')}" th:errors="*{address02}"></div> 57 58 <input type="submit" value="確認ページへ"> 59</form> 60</body> 61</html>

registConfirmhtml

1<!DOCTYPE html> 2<html xmlns:th="http://www.thymeleaf.org"> 3<head> 4<meta charset="UTF-8"> 5<title th:text="${title}">Insert title here</title> 6</head> 7<body> 8<h1>タイトル</h1> 9<p>入力内容をご確認ください</p> 10 11<div th:object="${employeeFormData}"> 12<p th:text="*{employeeId}"></p> 13<p th:text="*{employee_firstName}"></p> 14<p th:text="*{employee_firstName_kana}"></p> 15<p th:text="*{employee_lastName}"></p> 16<p th:text="*{employee_lastName_kana}"></p> 17<p th:text="*{sex}"></p> 18<p th:text="*{birthday}"></p> 19<p th:text="*{age}"></p> 20<p th:text="*{cellhone}"></p> 21<p th:text="*{addressNomber}"></p> 22<p th:text="*{address01}"></p> 23<p th:text="*{address02}"></p> 24 25<form method="post" action="#" th:action="@{/regist/form}"> 26 27 <input type="hidden" name="employeeId" th:value="*{employeeId}"> 28 <input type="hidden" name="employee_firstName" th:value="*{employee_firstName}"> 29 <input type="hidden" name="employee_firstName_kana" th:value="*{employee_firstName_kana}"> 30 <input type="hidden" name="employee_lastName" th:value="*{employee_lastName}"> 31 <input type="hidden" name="employee_lastName_kana" th:value="*{employee_lastName_kana}"> 32 <input type="hidden" name="sex" th:value="*{sex}"> 33 <input type="hidden" name="birthday}" th:value="*{birthday}}"> 34 <input type="hidden" name="age" th:value="*{age}"> 35 <input type="hidden" name="cellhone" th:value="*{cellhone}"> 36 <input type="hidden" name="address01" th:value="*{addressNomber}"> 37 <input type="hidden" name="address02" th:value="*{address02}"> 38 39 <input type="submit" value="戻る"> 40</form> 41 42<form method="post" action="#" th:action="@{/regist/complete}"> 43 44 <input type="hidden" name="employeeId" th:value="*{employeeId}"> 45 <input type="hidden" name="employee_firstName" th:value="*{employee_firstName}"> 46 <input type="hidden" name="employee_firstName_kana" th:value="*{employee_firstName_kana}"> 47 <input type="hidden" name="employee_lastName" th:value="*{employee_lastName}"> 48 <input type="hidden" name="employee_lastName_kana" th:value="*{employee_lastName_kana}"> 49 <input type="hidden" name="sex" th:value="*{sex}"> 50 <input type="hidden" name="birthday}" th:value="*{birthday}}"> 51 <input type="hidden" name="age" th:value="*{age}"> 52 <input type="hidden" name="cellhone" th:value="*{cellhone}"> 53 <input type="hidden" name="address01" th:value="*{addressNomber}"> 54 <input type="hidden" name="address02" th:value="*{address02}"> 55 56 <input type="submit" value="登録"> 57</form> 58</div> 59</body> 60</html>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2021/02/25 03:31

エラー中腹には何行目とかどの構文とか出ていると思います。その部分も提示してください
m.ts10806

2021/02/25 03:33

あと、ファイル名ではなく言語名を。 ```java ```html でないと言語のシンタックスハイライトが正しく効かないマークダウンの仕様のようです。
aaa11

2021/02/25 03:55

ご教授ありがとうございます。 htmlの記載ミスで自己解決しました。
m.ts10806

2021/02/25 04:01

あとマークダウンの修正を。 半永久的に残りますので、あとから誰かが参照する可能性は考慮してください
guest

回答1

0

自己解決

htmlの記載ミスでした。

投稿2021/02/25 03:54

aaa11

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2021/02/25 04:00

どこがどうミスでどうなおしたのか記載してください。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問