実現したいこと
ページを表示した時、フォームの重要度の文字化けを起こさず表示できるようにしたい
https://i.gyazo.com/e0134a5717b5dd6629de610fde341c76.png
該当のソースコード
/issueapp/IssueController.java
java
1package in.techcamp.issueapp; 2 3 4import org.apache.ibatis.annotations.Insert; 5import org.apache.ibatis.annotations.Mapper; 6 7@Mapper 8public interface IssueRepository { 9 @Insert("insert into issues (title, content, period, importance) values (#{title}, #{content}, #{period}, #{importance})") 10 void insert(String title, String content, String period, char importance); 11}
/issueapp/IssueForm.java
java
1package in.techcamp.issueapp; 2 3import lombok.Data; 4 5@Data 6public class IssueForm { 7 private String title; 8 private String content; 9 private String period; 10 private char importance; 11}
HTML
1<!DOCTYPE html> 2<html xmlns:th="http://www.thymeleaf.org"> 3<head> 4 <meta charset="UTF-8"> 5 <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"> 6 <title>イシュー新規作成</title> 7</head> 8<body> 9 10<header> 11 <a th:href="@{/}">IssueApp</a> 12</header> 13 14<div class="page-title"> 15 <h1>イシュー新規作成フォーム</h1> 16</div> 17 18<div class="form"> 19 <form action="#" th:action="@{/issues}" th:method="post" th:object="${issueForm}"> 20 <div class="form_title"> 21 <h2 class="column-title">タイトル</h2> 22 <input type="text" id="title" th:field="*{title}"> 23 </div> 24 <div class="form_content"> 25 <h2 class="column-title">内容</h2> 26 <textarea id="content" th:field="*{content}"></textarea> 27 </div> 28 29 <div class="form_period"> 30 <h2 class="column-title">期限</h2> 31 <input type="date" id="period" th:field="*{period}"> 32 </div> 33 34 <div class="form_importance"> 35 <h2 class="column-title">重要度</h2> 36 <input type="text" id="importance" th:field="*{importance}"> 37 </div> 38 39 <div class="form_submit"> 40 <button type="submit">作成</button> 41 </div> 42 </form> 43</div> 44</body> 45</html>
試したこと
何も入力していないのに�が1文字表示されている
試しにHTMLのinput typeをnumberなどに変えてみたら�が表示されなくなったのでtypeがtextの状態だと駄目
初歩的な内容ですがどなたかご教授下さい
補足情報(FW/ツールのバージョンなど)
Spring Boot 2.7.6

回答1件
あなたの回答
tips
プレビュー