前提・実現したいこと
SpringBootとthymeleafを使って開発を行っているのですが、Thymeleafが有効にならず困っています。
SpringInitializer,IntelliJ IDEAを使っての開発です。
また、Java8、Gradleを使っています。
該当ソースコード
TestController
1package com.example.test.Controller; 2 3import org.springframework.stereotype.Controller; 4import org.springframework.ui.Model; 5import org.springframework.web.bind.annotation.RequestMapping; 6import org.springframework.web.bind.annotation.RequestMethod; 7 8@Controller 9public class TestController { 10 @RequestMapping(value = "/", method = RequestMethod.GET) 11 public String test(Model model){ 12 model.addAttribute("msg", "TestMessage"); 13 return "top"; 14 } 15}
html
1<!DOCTYPE html> 2<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"> 3<head> 4 <meta charset="UTF-8"> 5 <title>TopPage</title> 6</head> 7<body> 8 <p>Test</p> 9 <p th:text="${msg}"/> 10</body> 11</html>
dependencies
1dependencies { 2 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 3 implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 4 implementation 'org.springframework.boot:spring-boot-starter-web' 5 runtimeOnly 'org.springframework.boot:spring-boot-devtools' 6 runtimeOnly 'mysql:mysql-connector-java' 7 testImplementation 'org.springframework.boot:spring-boot-starter-test' 8}
該当のソースコード
上のコードを使い、
Gradle bootrunを行っても、
となってしまい、thymeleafの部分が表示されません。
試したこと
検索を行い調べてみたものの、これといったものがなく何も手をつけられないという感じです。
初心者なので至らない部分もあるかと思いますが、よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。