前提
SpringBoot 初心者です。
消費税計算のプログラムを作っています。事業区分ごとの税込売上高を入力し、「計算」のボタンをクリックすると、税額算出画面に計算式と納付税額が表示される仕組みです。
ところが、Thymeleafを使ったhtmlのトップ画面を出そうとしているのですけれど、これが出ません。
次のようなエラーメッセージが出るのですが、その指摘する箇所を検討してみても正しいように見えて原因が分かりません。
どこに根本的な誤りがあるのかをできましたらご教授願いたいのですが。
実現したいこと
トップ画面を表示する機能を動作するようにする。
発生している問題・エラーメッセージ
トップ画面が出ない。
Caused by: org.attoparser.ParseException: Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor' (template: "taxCalc/top" - line 25, col 59)
該当のソースコード
java
1package com.example.demo.web; 2 3import org.springframework.stereotype.Controller; 4import org.springframework.web.bind.annotation.GetMapping; 5import org.springframework.web.bind.annotation.ModelAttribute; 6import org.springframework.web.bind.annotation.PostMapping; 7import org.springframework.web.bind.annotation.RequestMapping; 8 9@Controller 10@RequestMapping("taxCalc") 11public class taxCalcController { 12 13@ModelAttribute 14SalesForm setupForm() { 15 return new SalesForm(); 16} 17 18@GetMapping 19String top() { 20 return "taxCalc/top"; 21} 22 23@PostMapping(params="taxCalc") 24String result() { 25 return "taxCalc/result"; 26} 27 28@GetMapping(params="goToTop") 29String goToTop() { 30 return "taxCalc/top"; 31} 32} 33
java
1package com.example.demo.web; 2 3import javax.validation.constraints.PositiveOrZero; 4 5public class SalesForm { 6 @PositiveOrZero 7 private Integer sales1_8; 8 @PositiveOrZero 9 private Integer salesRET1_8; 10 @PositiveOrZero 11 private Integer sales1_10; 12 @PositiveOrZero 13 private Integer salesRET1_10; 14 @PositiveOrZero 15 private Integer sales2_8; 16 @PositiveOrZero 17 private Integer salesRET2_8; 18 @PositiveOrZero 19 private Integer sales2_10; 20 @PositiveOrZero 21 private Integer salesRET2_10; 22 @PositiveOrZero 23 private Integer sales3_8; 24 @PositiveOrZero 25 private Integer salesRET3_8; 26 @PositiveOrZero 27 private Integer sales3_10; 28 @PositiveOrZero 29 private Integer salesRET3_10; 30 @PositiveOrZero 31 private Integer sales4_8; 32 @PositiveOrZero 33 private Integer salesRET4_8; 34 @PositiveOrZero 35 private Integer sales4_10; 36 @PositiveOrZero 37 private Integer salesRET4_10; 38 @PositiveOrZero 39 private Integer sales5_10; 40 @PositiveOrZero 41 private Integer salesRET5_10; 42 @PositiveOrZero 43 private Integer sales6_10; 44 @PositiveOrZero 45 private Integer salesRET6_10; 46} 47
html
1<!DOCTYPE html> 2<html xmlns:th="http://www.thymeleaf.org"> 3<head> 4<meta charset="UTF-8"> 5<title>消費税計算</title> 6</head> 7<body> 8<h1>消費税計算画面(簡易課税制度による)</h1> 9<form th:action="@{/taxCalc/result}" th:object="${salesForm}" method="post"> 10<div id="userForm-errors" th:errors="*{*}" class="error-message-list"></div> 11<table border="1"> 12 <tr> 13 <th>事業区分</th> 14 <th>業種</th> 15 <th>みなし仕入率</th> 16 <th>8%売上(税込)</th> 17 <th>8%売上返還(税込)</th> 18 <th>10%売上(税込)</th> 19 <th>10%売上返還(税込)</th> 20 </tr> 21 <tr> 22 <th>第一種事業</th> 23 <th>卸売業</th> 24 <th>90%</th> 25 <td><input type="text" id="sales1_8" name="sales1_8" th:field="*{sales1_8}" value=0 th:errorclass="error-input"/></td> 26 <td><input type="text" id="salesRET1_8" name="salesRET1_8" th:field="*{salesRET1_8}" value=0 th:errorclass="error-input"/></td> 27 <td><input type="text" id="sales1_10" name="sales1_10" th:field="*{sales1_10}" value=0 th:errorclass="error-input"/></td> 28 <td><input type="text" id="salesRET1_10" name="salesRET1_10" th:field="*{salesRET1_10}" value=0 th:errorclass="error-input"/></td> 29 </tr> 30 <tr> 31 <th>第二種事業</th> 32 <th></th> 33 <th>80%</th> 34 <td><input type="text" id="sales2_8" name="sales2_8" th:field="*{sales2_8}" value=0 th:errorclass="error-input"/></td> 35 <td><input type="text" id="salesRET2_8" name="salesRET2_8" th:field="*{salesRET2_8}" value=0 th:errorclass="error-input"/></td> 36 <td><input type="text" id="sales2_10" name="sales2_10" th:field="*{sales2_10}" value=0 th:errorclass="error-input"/></td> 37 <td><input type="text" id="salesRET2_10" name="salesRET2_10" th:field="*{salesRET2_10}" value=0 th:errorclass="error-input"/></td> 38 </tr> 39 <tr> 40 <th>第三種事業</th> 41 <th></th> 42 <th>70%</th> 43 <td><input type="text" id="sales3_8" name="sales3_8" th:field="*{sales3_8}" value=0 th:errorclass="error-input"/></td> 44 <td><input type="text" id="salesRET3_8" name="salesRET3_8" th:field="*{salesRET3_8}" value=0 th:errorclass="error-input"/></td> 45 <td><input type="text" id="sales3_10" name="sales3_10" th:field="*{sales3_10}" value=0 th:errorclass="error-input"/></td> 46 <td><input type="text" id="salesRET3_10" name="salesRET3_10" th:field="*{salesRET3_10}" value=0 th:errorclass="error-input"/></td> 47 </tr> 48 <tr> 49 <th>第四種事業</th> 50 <th></th> 51 <th>60%</th> 52 <td><input type="text" id="sales4_8" name="sales4_8" th:field="*{sales4_8}" value=0 th:errorclass="error-input"/></td> 53 <td><input type="text" id="salesRET4_8" name="salesRET4_8" th:field="*{salesRET4_8}" value=0 th:errorclass="error-input"/></td> 54 <td><input type="text" id="sales4_10" name="sales4_10" th:field="*{sales4_10}" value=0 th:errorclass="error-input"/></td> 55 <td><input type="text" id="salesRET4_10" name="salesRET4_10" th:field="*{salesRET4_10}" value=0 th:errorclass="error-input"/></td> 56 </tr> 57 <tr> 58 <th>第五種事業</th> 59 <th></th> 60 <th>50%</th> 61 <td></td> 62 <td></td> 63 <td><input type="text" id="sales5_10" name="sales5_10" th:field="*{sales5_10}" value=0 th:errorclass="error-input"/></td> 64 <td><input type="text" id="salesRET5_10" name="salesRET5_10" th:field="*{salesRET5_10}" value=0 th:errorclass="error-input"/></td> 65 </tr> 66 <tr> 67 <th>第六種事業</th> 68 <th>不動産業</th> 69 <th>40%</th> 70 <td></td> 71 <td></td> 72 <td><input type="text" id="sales6_10" name="sales6_10" th:field="*{sales6_10}" value=0 th:errorclass="error-input"/></td> 73 <td><input type="text" id="salesRET6_10" name="salesRET6_10" th:field="*{salesRET6_10}" value=0 th:errorclass="error-input"/></td> 74 </tr> 75</table> 76<input type="submit"name="taxCalc" value="計算"/> 77</form> 78</body> 79</html>
試したこと
エラーの起きている箇所をコメントアウトしたのちただの<td></td>に置き換えて再実行しても、次の行にエラーが移るだけ。
エラーを指摘された箇所(nameの名前”sales1_8"のs)を含め名前に使用する文字に不適当はない。
補足情報(FW/ツールのバージョンなど)
回答1件
あなたの回答
tips
プレビュー