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

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

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

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

Spring Boot

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

Q&A

解決済

1回答

7611閲覧

springbootについて質問

退会済みユーザー

退会済みユーザー

総合スコア0

Java

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

Spring Boot

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

0グッド

0クリップ

投稿2020/05/06 06:28

前提・実現したいこと

ここに質問の内容を詳しく書いてください。
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。

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

エラーメッセージ

There was an unexpected error (type=Internal Server Error, status=500).
An error happened during template parsing (template: "class path resource [templates/new.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/new.html]")
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(
org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362)
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
at org.springframework.web.servlet.DispatcherServlet.doDispatch()

at org.springframework.web.servlet.FrameworkServlet.processRequest(6) at org.springframework.web.servlet.FrameworkServlet.doPost() at org.springframework.web.servlet.FrameworkServlet.service at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter( at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(19) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at

Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "d1" (template: "new" - line 38, col 5)

... 48 more

Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "d1" (template: "new" - line 38, col 5)

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'd1' cannot be found on object of type 'com.example.demo.domain.Date' - maybe not public or not valid?

該当のソースコード

ソースコード  package com.example.demo.domain; @Entity @Table(name="date") public class Date { private LocalDate d1; @GeneratedValue private Long id; @Id private String word; private String name; private int year; private int month; private int day; public void setId(Long id) { this.id=id; } public Long getId() { return id; } public void setWord(String word) { this.word=word; } public String getWord() { return word; } public void setName(String name) { this.name=name; } public String getName() { return name; } public void setYear(int year) { this.year=year; } public int getYear() { return year; } public void setMonth(int month) { this.month=month; } public int getMonth() { return month; } public void setDay(int day) { this.day=day; } public int getDay() { return day; } public void setL(LocalDate d1) { this.d1=d1; } public LocalDate getL() { return d1; } public void calculate(LocalDate X) { LocalDate R= X.plusYears(getYear()); LocalDate R1= R.plusMonths(getMonth()); LocalDate d1= R1.plusDays(getDay()); } package com.example.demo.controller; @Controller @RequestMapping("/") public class dateController { @Autowired dateMapper mapper; @Autowired private dateRepository repository; @GetMapping public String top(Model model) { model.addAttribute("dates", mapper.findAll()); return "new"; } @PostMapping("/new") public String create(@ModelAttribute Date date,Model model) { mapper.save(date); return "redirect:/"; } @GetMapping("/edit/{word}") public ModelAndView edit(@PathVariable String word, @ModelAttribute Date date ,ModelAndView mav) { mav.addObject("date",mapper.findOne(word) ); mav.setViewName("edit"); return mav; } @PostMapping("/edit") @Transactional public String update( @ModelAttribute("date")Date date, Model model) { mapper.update(date); return "redirect:/"; } @PostMapping("/calculate") public String cal( @RequestParam("d")LocalDate d ,Model model) { List<Date> D=repository.findAll(); for(int i=0;D.size()>i;i++) { D.get(i).calculate(d); } model.addAttribute("R",repository.findAll()); return "new"; } @PostMapping("/delete/{word}") public String delete(@PathVariable String word ,Model model) { mapper.delete(word); return "redirect:/"; } } html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> 計算式 <th:text="${msg}"> <form th:objext="${form}" th:method="post" th:action="@{/new}"> 日付ID <input type="text" name="word" th:value="${word}" ><br> 名前<input type="text" name="name" th:value="${name}"><br> 加減(Y)<input type="text" name="year" th:value="${year}"><br> 加減(M)<input type="text" name="month" th:value="${month}"><br> 加減(D)<input type="text" name="day" th:value="${day}"><br> <button type="submit">登録</button> </form> 日付 <form method="post" th:action="@{/calculate}" th:object="${date}" ><input type="datetime" placeholder="yyyy/MM/dd" name="d" th:value="${d}"> <button value="submit">実行</button> </form> <td th:text="${result}"></td> <table> <tr > <td>id</td> <td>日付ID</td> <td>名前</td> <td >結果</td> <td >加減(Y/M/D)</td> </tr> <tr th:each="obj:${R}" th:object="${obj}"> <td th:text="*{id}"></td> <td th:text="*{word}" ></td> <td th:text="*{name}"></td> <td th:text="*{d1}" ></td> <td th:text="|*{year}/*{month}/*{day}|"> <td><form method="get" th:action="@{/edit/{word}(word=*{word})}"> <button value="submit">更新</button></form></td> <td><form method="post" th:action="@{/delete/{word}(word=*{word})}"> <button value="submit">削除</button> </form></td> </table> </body> </html> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.example.demo.mapper.dateMapper"> <select id="findAll" resultType="com.example.demo.domain.Date"> select * from date </select> <select id="findOne" resultType="com.example.demo.domain.Date"> select * from date where word= #{word} </select> <insert id="save" useGeneratedKeys="true" keyProperty="word"> insert into date (id,word, name , year,month,day) values(#{id},#{word}, #{name}, #{year},#{month},#{day}) </insert> <update id="update"> update date set name=#{name}, year=#{year},month=#{month},day=#{day} where word= #{word} </update> <delete id="delete"> delete from date where word = #{word} </delete> </mapper> package com.example.demo.mapper; @Mapper public interface dateMapper { List<Date> findAll(); Date findOne(String word); void save(Date date); void update(Date date); void delete(String word); } ### 試したこと ここに問題に対して試したことを記載してください。 ### 補足情報(FW/ツールのバージョンなど) springboot eclipse  ![イメージ説明](5b93c6dcdc6f10266d717dfe02357ba6.png) ここにより詳細な情報を記載してください。 日付IDをプライマリーキーにして年、月、日の加減 の数値を計算式として登録して任意の日付に対して結果を表示させるアプリを作っていますが、計算結果と登録した式を一緒に表示させることができません。

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

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

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

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

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

m.ts10806

2020/05/06 06:30

>springbootについて質問 というのはタグで分かるので、要件を記載してください。 コードやエラーはマークダウンのcode機能を利用してご提示ください。 https://teratail.com/questions/238564 質問本文に質問テンプレート文そのままと思わしき情報が散見されます。 ノイズとなりますので削ってください。
m.ts10806

2020/05/06 09:02

>無事解決しました とコメントされてますが質問は「受付中」のままです。 https://teratail.com/help/question-tips#questionTips4 ただ、コードのマークダウン対応ができてないと読む気がしない人も多いです。インデントもなく、文章とコードの境目が明確にならないし、1クリックでコピペもできない。 ベストアンサーを選ぶ前に、コードのマークダウンだけでも対応しておいてください。覚えとかないと損しかありません。
guest

回答1

0

ベストアンサー

Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "d1" (template: "new" - line 38, col 5)

というエラーですから、getD1()というメソッドが定義されていないから、でしょう。

もしくは、

public LocalDate getL() { return d1; }

このメソッドを使いたいのであれば、テンプレートを修正するか。

<td th:text="*{d1}" ></td> -> <td th:text="*{l}" ></td>

投稿2020/05/06 06:37

shiketa

総合スコア3971

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

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

退会済みユーザー

退会済みユーザー

2020/05/06 06:56

無事解決しました。ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問