SpringBoot + Thymeleaf:プロパティまたはフィールドの「name」の型のオブジェクトで見つけることができません

ルーカス:

私はThymeleafとHTMLファイル内のオブジェクトを表示したいと思いますが、それは言う、「プロパティまたはフィールドの 『name』 『がcom.example.demo.Entities.PeopleInformation』タイプのオブジェクト上で見つけることができません - ?多分、公開されていないか有効ではありません」

ページのための私のコントローラのこと

package com.example.demo.Controller;

import java.util.ArrayList;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.Entities.PeopleInformation;

@Controller
public class HelloWorld {

    @GetMapping(value= "/list_contacts")
    public String showContacts(Model m){
        ArrayList<PeopleInformation> kontakte = new ArrayList<PeopleInformation>();
        PeopleInformation a = new PeopleInformation("Lutz","Walter","0152 222556","Aktuell");
        PeopleInformation b = new PeopleInformation("Bosch","Holger","0152 567345","Aktuell");
        PeopleInformation c = new PeopleInformation("Schindler","Nicole","0152 220022","Aktuell");
        kontakte.add(a);
        kontakte.add(b);
        kontakte.add(c);
        m.addAttribute("kontakte",kontakte);
        return "list_contacts";
    }
}

その実体は、ロンボクを使用しています

package com.example.demo.Entities;

import org.springframework.data.annotation.Id;

import com.microsoft.spring.data.gremlin.annotation.Vertex;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor @Setter @Getter 
public class PeopleInformation {
    @Id
    private Long id;
    private String name;
    private String vorname;
    private String telefon;
    private String status;

    public PeopleInformation(String name,String vorname,String telefon,String status) {
        this.name = name;
        this.vorname = vorname;
        this.telefon = telefon;
        this.status = status;
    }
}

そして、それは、Thymeleafと私のHTMLファイルです

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Kontakt-Liste</title>
</head>
<body>
     <div>
         <table border="1">
            <tr>
               <th>Name</th>
               <th>Vorname</th>
               <th>Telefon</th>
               <th>Status</th>
            </tr>
            <tr th:each ="kontakte : ${kontakte}">
               <td th:utext="${kontakte.name}">...</td>
               <td th:utext="${kontakte.vorname}">...</td>
               <td th:utext="${kontakte.telefon}">...</td>
               <td th:utext="${kontakte.status}">...</td>
            </tr>
         </table>
      </div>
</body>
</html>

誰かが問題、感謝を見つけることができます:)

Wolobi:

あなたがデータを見たい場合は、PeopleInformationエンティティにゲッターを宣言する必要があります

このような:

    public Long getId() {
    return id;
}

public String getName() {
    return name;
}

public String getVorname() {
    return vorname;
}

public String getTelefon() {
    return telefon;
}

public String getStatus() {
    return status;
}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=16894&siteId=1