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

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

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

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

Q&A

解決済

エラー List は総称ではありません。引数 <Product> でパラメーター化できません

退会済みユーザー

退会済みユーザー

総合スコア0

Thymeleaf

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

1回答

0グッド

0クリップ

9436閲覧

投稿2019/08/30 05:06

html

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

java

1package com.example.demo; 2 3 4 import java.awt.List; 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 }
package com.example.demo; public class Product {   private String hensyu; private String adress; private String country; private int age; private String name; private int tel; //コンストラクタ public void Person(String hensyu, String adress, String country, int age, String name,int tel) { this.hensyu = "dummy"; this.adress= "dummy"; this.country = "dummy"; this.age= 12; this.name = "dummy"; this.Num = 111; } public String getHensyu() { return hensyu; } public void setHensyu(String hensyu) { this.hensyu = hensyu; } public String getAdress() { return adress; } public void setAdress(String adress) { this.adress = adress; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getTel() { return tel; } public void setTel(int tel) { this.tel = tel; } } }

spring bootで個人情報を登録する画面を作成中です。thymeleafで表示させたいのですが、

ERROR 9596 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.Error: Unresolved compilation problem:
型 List は総称ではありません。引数 <Product> でパラメーター化できません

と表示されます。この場合どうしたらいいのか教えて頂きたいです。

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

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

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

下記のような質問は推奨されていません。

  • 質問になっていない投稿
  • スパムや攻撃的な表現を用いた投稿

適切な質問に修正を依頼しましょう。

回答1

1

ベストアンサー

Test クラスで import しているクラスが誤っていると思います。
java.awt.List ではなく java.util.List です。

投稿2019/08/30 06:53

d-yosh

総合スコア270

inumaeda👍を押しています

下記のような回答は推奨されていません。

  • 質問の回答になっていない投稿
  • スパムや攻撃的な表現を用いた投稿

このような回答には修正を依頼しましょう。

回答へのコメント

退会済みユーザー

退会済みユーザー

2019/08/30 06:57

削除したら実行できました!!ありがとうございます!!
退会済みユーザー

退会済みユーザー

2019/08/30 07:02

products.add(new Product()); ↓ products.add(new Product(123,"str",321,"str2"111,222,333,"wer","tyu")); に変更し、値をaddしてみたのですが、表示されません。 java.lang.Error: Unresolved compilation problems: コンストラクター Product(int, String, int, String, int, int, String, String) は未定義です トークン "111" に構文エラーがあります。このトークンを削除してください とエラーが出ました。どうしたら表示されるか教えていただけないでしょうか?

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.83%

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

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

質問する

関連した質問

同じタグがついた質問を見る

Thymeleaf

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