Q&A
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件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
退会済みユーザー
2019/08/30 06:57
退会済みユーザー
2019/08/30 07:02