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

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

新規登録して質問してみよう
ただいま回答率
85.46%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Spring

Spring Framework は、Javaプラットフォーム向けのオープンソースアプリケーションフレームワークです。 Java Platform上に、 Web ベースのアプリケーションを設計するための拡張機能が数多く用意されています。

Q&A

0回答

2030閲覧

An error happened during template parsing 画面が表示できません

goriwo

総合スコア17

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Spring

Spring Framework は、Javaプラットフォーム向けのオープンソースアプリケーションフレームワークです。 Java Platform上に、 Web ベースのアプリケーションを設計するための拡張機能が数多く用意されています。

0グッド

0クリップ

投稿2021/04/14 13:33

前提・実現したいこと

javaでmvcを理解するためform画面の別画面を作っていたのですがエラーが発生してビューが表示できません
初学者なのでお手柔らかにお願いします

発生している問題・エラーメッセージ

There was an unexpected error (type=Internal Server Error, status=500). An error happened during template parsing (template: "class path resource [templates/root/form2.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/root/form2.html]") Caused by: org.attoparser.ParseException: Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor' (template: "root/form2" - line 72, col 10)

該当のソースコード

package com.example.demo.controllers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import com.example.demo.models.InquiryForm; import com.example.demo.models.InquiryForm2; import com.example.demo.repositries.InquiryRepository; @Controller @RequestMapping("/") public class RootController { @Autowired InquiryRepository repository; @GetMapping public String index() { return "root/index"; } @GetMapping("/form") public String form(InquiryForm inquiryForm) { return "root/form"; } @PostMapping("/form") public String form(@Validated InquiryForm inquiryForm, BindingResult bindingResult, Model model) { if (bindingResult.hasErrors()) { return "root/form"; } // RDBと連携できることを確認しておきます。 repository.saveAndFlush(inquiryForm); inquiryForm.clear(); model.addAttribute("message", "お問い合わせを受け付けました。"); return "root/form"; } @GetMapping("/form2") public String form2(InquiryForm2 inquiryForm2) { return "root/form2"; } @PostMapping("/form2") public String form2(@Validated InquiryForm2 inquiryForm2, BindingResult bindingResult2, Model model2) { if (bindingResult2.hasErrors()) { return "root/form2"; } // repository.saveAndFlush(inquiryForm2); inquiryForm2.clear(); model2.addAttribute("message","バージョンform2"); return "root/form2"; } }
package com.example.demo.models; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import lombok.Data; @Data @Entity @Table(name = "inquiry") public class InquiryForm2 implements Serializable { private static final long serialVersionUID = -6647247658748349084L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @NotBlank @Size(max = 10) private String name; @NotBlank @Email private String mail; @NotBlank @Size(max = 400) private String content; public void clear() { name = null; mail = null; content = null; } }
<!doctype html> <html xmlns:th="http://www.thymeleaf.org" lang="ja"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>ポートフォリオサイト</title> <link rel="stylesheet" media="all" th:href="@{/css/ress.min.css}" /> <link rel="stylesheet" media="all" th:href="@{/css/style.css}" /> <script th:src="@{/js/jquery-2.1.4.min.js}"></script> <script th:src="@{/js/style.js}"></script> <!-- Favicon --> <link rel="icon" type="image/png" th:href="@{/img/favicon.png}"> </head> <body> <header> <div class="container"> <div class="row"> <div class="col span-12"> <div class="head"> <h1> <a th:href="@{/}">PORTFOLIO</a> </h1> </div> </div> </div> <div class="row"> <div class="col span-12"> <nav> <div id="open"> <img th:src="@{/img/button.png}"> </div> <div id="close"> <img th:src="@{/img/button2.png}"> </div> <div id="navi"> <ul> <li><a th:href="@{/}">ホーム</a></li> <li><a th:href="@{/form}">お問い合わせ</a></li> </ul> </div> </nav> </div> </div> </div> </header> <div class="mainimg"> <img th:src="@{/img/subimg.jpg}" alt="お問い合わせ画像"> </div> <main> <article> <div class="container"> <div class="row"> <div class="col span-12"> <div class="breadcrumb"> <ul> <li><a th:href="@{/demo}">ホーム</a> > お問い合わせ</li> </ul> </div> <th:block th:if="message != null"> <h2 th:class="msg" th:text="${message}"></h2> </th:block> <h2 class="underline">フォームバージョン2</h2> <form th:action="@{/form2}" th:object="${inquiryForm}" method="post"> <p> <label for="name">お名前</label> <input class="full-width" type="text" id="name" name="name" maxlength="10" th:field="*{name}"> <span th:if="${#fields.hasErrors('name')}" th:errors="*{name}" th:class="msg"></span> </p> <p> <label for="email">メールアドレス</label> <input class="full-width" type="email" id="mail" name="mail" th:field="*{mail}"><span th:if="${#fields.hasErrors('mail')}" th:errors="*{mail}" th:class="msg"></span> </p> <p> <label for="message">お問い合わせ内容</label> <textarea class="full-width" id="content" name="content" th:field="*{content}"></textarea> <span th:if="${#fields.hasErrors('content')}" th:errors="*{content}" th:class="msg"></span> </p> <p> <input class="button" type="submit" value="送信"> </p> </form> </div> </div> </div> </article> </main> <footer> <div class="container"> <div class="row"> <div class="col span-12"> <h5>お知らせ</h5> <p>電話での問合せは承っておりません。</p> <p>回答にお時間頂くことがございます。予めご了承ください。</p> </div> </div> </div> </footer> <p id="pagetop"> <a href="#">TOP</a> </p> </body> </html>

試したこと

form2"-行72、列10がおかしいとかいてあるのですがなにが悪いのかわかりませんでした

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問