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

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

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

Thymeleaf(タイムリーフ)とは、Java用のテンプレートエンジンで、特定のフレームワークに依存せず使用することが可能です。

Q&A

1回答

323閲覧

コントローラーからビューに表示できない

退会済みユーザー

退会済みユーザー

総合スコア0

Thymeleaf

Thymeleaf(タイムリーフ)とは、Java用のテンプレートエンジンで、特定のフレームワークに依存せず使用することが可能です。

0グッド

0クリップ

投稿2019/08/30 08:17

html

1<!doctype html> 2<html><head lang="jp"> 3<meta charset="utf-8"> 4</head> 5<table class=""> 6 <thead> 7 <tr> 8 <th>編集</th> 9 <th>住所</th> 10 <th>国籍</th> 11 <th>年齢</th> 12 <th>氏名</th> 13 <th>電話番号</th> 14 </tr> 15 </thead> 16 <tbody> 17 <tr th:each="obj : ${products}"> 18 <td class="text-center" th:text="${obj.hensyu}"> 19 <a class="" data-target="#" target="_blank" href="" > 20 <span class="">dummy</span> 21 </a> 22 </td> 23 <td type="hidden" class="" name="" th:text="${obj.adress}" ></td> 24 <td class="" name="" th:text="${obj.country}">dummy</td> 25 <td class="" name="" th:text="${obj.age}" >dummy</td> 26 <td class=""><span name="" th:text="${obj.name}"></span>dummy<span name="">dummy</span></td> 27 <td class="" name="" th:text="${obj.tel}">dummy</td> 28 </tr> 29 </tbody> 30 </table>

Java

1package com.example.demo; 2 3 4 5 import java.util.ArrayList; 6 7 import org.springframework.beans.factory.annotation.Autowired; import 8 org.springframework.stereotype.Controller; import 9 org.springframework.ui.Model; import 10 org.springframework.web.bind.annotation.RequestMapping; 11 12 @Controller public class Test { 13 14 15 @RequestMapping(value="user") 16 17 public String User( Model Model) { 18 19 List<Product> products= new ArrayList<>(); 20 21 products.add(new Product()); 22 23 Model.addAttribute("products",products); 24 25 26 27 return "index.html"; 28 } 29 }

Java クラス

1 2 3package com.example.demo; 4 5public class Product { 6 7 8  private String hensyu; 9 private String adress; 10 private String country; 11 private int age; 12 private String name; 13 private int tel; 14 15 16 17 18 public void Person(String hensyu, String adress, String country, int age, String name,int tel) { 19 this.hensyu = "dummy"; 20 this.adress= "dummy"; 21 this.country = "dummy"; 22 this.age= 12; 23 this.name = "dummy"; 24 this.Num = 111; 25 } 26 27 public String getHensyu() { 28 return hensyu; 29 } 30 31 32 33 public void setHensyu(String hensyu) { 34 this.hensyu = hensyu; 35 } 36 37 38 39 public String getAdress() { 40 return adress; 41 } 42 43 44 45 public void setAdress(String adress) { 46 this.adress = adress; 47 } 48 49 50 51 public String getCountry() { 52 return country; 53 } 54 55 56 57 public void setCountry(String country) { 58 this.country = country; 59 } 60 61 62 63 public int getAge() { 64 return age; 65 } 66 67 68 69 public void setAge(int age) { 70 this.age = age; 71 } 72 73 74 75 public String getName() { 76 return name; 77 } 78 79 80 81 public void setName(String name) { 82 this.name = name; 83 } 84 85 86 87 public int getTel() { 88 return tel; 89 } 90 91 92 93 public void setTel(int tel) { 94 this.tel = tel; 95 } 96 97 98 } 99 100} 101コード

Productクラスで定義した値がviewに表示されないです。どうしたらいいのか教えて頂きたいです。

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

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

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

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

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

guest

回答1

0

おそらく

index.html.html

がないからでは?

※ 理由は公式ドキュメント参照*

投稿2019/09/01 08:36

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問