Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 弹簧靴和百里环:字段';名称';在null上找不到_Spring Mvc_Spring Boot - Fatal编程技术网

Spring mvc 弹簧靴和百里环:字段';名称';在null上找不到

Spring mvc 弹簧靴和百里环:字段';名称';在null上找不到,spring-mvc,spring-boot,Spring Mvc,Spring Boot,我无法在模板页面中显示模型中对象的字段。我已经检查了StackOverFlow上的类似问题,但它们都指向一个错误的命名(使用了model name!=EL表达式)。我已经仔细检查过了,但仍然找不到问题的原因。 这是我的html: <!DOCTYPE HTML> <html xmlns:th="http://www.thymeleaf.org"> <head> <title>Spring Boot Thymeleaf Example</titl


我无法在模板页面中显示模型中对象的字段。我已经检查了StackOverFlow上的类似问题,但它们都指向一个错误的命名(使用了model name!=EL表达式)。我已经仔细检查过了,但仍然找不到问题的原因。 这是我的html:

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring Boot Thymeleaf Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<body>
<h2>Hello</h2>
<table>

   <tr th:each="Persons:${persons}">
       <th>Name</th>
       <th>Surname</th>
        <td th:text="${person.name}" />
        <td th:text="${person.surname}" />
    </tr>
</tbody>


</table>
</body>
</html>
请求“/人”页面时,显示以下错误:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'name' cannot be found on null

您能建议我如何解决这个问题吗?

您的th:中的变量
Persons
的拼写与迭代中的不同。按如下方式更改代码:

 <tr th:each="person : ${persons}">
   <th>Name</th>
   <th>Surname</th>
    <td th:text="${person.name}" />
    <td th:text="${person.surname}" />
</tr>

名称
姓

th:中的变量
Persons
的拼写与迭代中的不同。按如下方式更改代码:

 <tr th:each="person : ${persons}">
   <th>Name</th>
   <th>Surname</th>
    <td th:text="${person.name}" />
    <td th:text="${person.surname}" />
</tr>

名称
姓

此处输入错误


th:each=“Persons:${Persons}
更改为
th:each=“Persons:${Persons}
此处键入错误


th:each=“Persons:${Persons}
更改为
th:each=“Persons:${Persons}

OMG。抱歉,我以为第一个字符串“Person”只是要在页面中打印的文本,对框架没有任何影响。抱歉,从后台删除JSF需要时间:-)OMG。抱歉,我以为第一个字符串“Person”只是要在页面中打印的文本,对框架没有任何影响。抱歉,从您的后台删除JSF需要时间:-)谢谢您提供解决方案。@Carla当然。但是15分钟前回答了!谢谢你也提供了解决方案。@Carla当然。但是15分钟前回答了!
 <tr th:each="person : ${persons}">
   <th>Name</th>
   <th>Surname</th>
    <td th:text="${person.name}" />
    <td th:text="${person.surname}" />
</tr>