Javascript org.thymeleaf.exceptions.TemplateProcessingException:异常评估SpringEL表达式:";ServiceAmc.id“的名称;(结果:30)
这是我的SerCorAmc.html文件,其中有一个按钮,单击按钮后showResult()方法将调用它,它将调用包含url的控制器,如AcquireServiceCorporateTeamCforMDetailSamcJavascript org.thymeleaf.exceptions.TemplateProcessingException:异常评估SpringEL表达式:";ServiceAmc.id“的名称;(结果:30),javascript,java,Javascript,Java,这是我的SerCorAmc.html文件,其中有一个按钮,单击按钮后showResult()方法将调用它,它将调用包含url的控制器,如AcquireServiceCorporateTeamCforMDetailSamc <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>ServiceCorporateAmcForm</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script type="text/javascript"
src="http://code.jquery.com/jquery.min.js"></script>
</head>
<body>
<div>
<button onclick="showResult()">ServiceCorporateAmc</button>
</div>
<div id="show"></div>
<script type="text/javascript">
function showResult(){
$("#show").load("acquireServiceCorporateAmcFormDetailsAMC");
}
</script>
</body>
</html>
This is my Controller, In which list will pass to the results.html
package com.control;
import com.model.service.ServiceCorporateAmc;
import com.repo.ServiceCorporateAmcRepo;
import java.util.Iterator;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class ServiceCorAmcController {
@Autowired
private ServiceCorporateAmcRepo serviceCorporateAmcRepo;
@RequestMapping(value="acquireServiceCorporateAmcFormDetailsAMC", method=RequestMethod.GET)
public String selectServiceCorporateAmcFormDetailsss(@ModelAttribute ServiceCorporateAmc serviceCorporateAmc,Model model)
{
List listServiceCorporateAmc= serviceCorporateAmcRepo.findAllData(); model.addAttribute("ServiceAmcs",listServiceCorporateAmc);
Iterator itr=listServiceCorporateAmc.iterator();
while(itr.hasNext()){
System.out.println(itr.next());
}
return "results::resultsList";
//return listServiceCorporateAmc;
}
}
This is my results.html file it will display the results of Controller
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"lang="en">
<head>
<title>ServiceCorporateAmcForm</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div th:fragment="resultsList" th:unless="${#lists.isEmpty(ServiceAmcs)}" >
<table>
<thead>
<tr>
<!--<th th:text="#{results.ServiceAmcs.id}">Id</th>
<th th:text="#{results.ServiceAmcs.customerID}">Customer ID</th>
<th th:text="#{results.ServiceAmcs.escalation}">Escalation</th>
<th th:text="#{results.ServiceAmcs.servicerequestcreatedby}">Service Request Created By</th>-->
<th>Id</th>
<th >Customer ID</th>
<th>Escalation</th>
<th>Service Request Created By</th>
</tr>
</thead>
<tbody>
<tr th:each="ServiceAmc : ${ServiceAmcs}">
// I am getting error overhere
<td th:text="${ServiceAmc.id}">id</td>
<td th:text="${ServiceAmc.customerID}"> CustomerID</td>
<td th:text="${ServiceAmc.escalation}">Escalation</td>
<td th:text="${ServiceAmc.servicerequestcreatedby}">ServiceRequestCreatedBy</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
ServiceCorporateTeamCform
服务公司
函数showResult(){
$(“#show”).load(“AcquireServiceCorporateTeamCformDetailSamc”);
}
这是我的控制器,其中的列表将传递到results.html
包com.control;
导入com.model.service.serviceComporateTeamc;
导入com.repo.ServiceCorporateAmcRepo;
导入java.util.Iterator;
导入java.util.List;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.stereotype.Controller;
导入org.springframework.ui.Model;
导入org.springframework.web.bind.annotation.ModelAttribute;
导入org.springframework.web.bind.annotation.RequestMapping;
导入org.springframework.web.bind.annotation.RequestMethod;
@控制器
公共类ServiceCoramController{
@自动连线
私人服务公司TeamCrepo服务公司TeamCrepo;
@RequestMapping(value=“AcquireServiceCorporateTeamCformdetailSamc”,method=RequestMethod.GET)
公共字符串selectServiceCorporateTeamCforMDetailSss(@ModelAttribute ServiceCorporateTeamC ServiceCorporateTeamC,Model Model)
{
List ListServiceCorporateTeamc=ServiceCorporateTeamCrepo.findAllData();model.addAttribute(“ServiceAMS”,ListServiceCorporateTeamc);
迭代器itr=ListServiceCorporateTeamc.Iterator();
而(itr.hasNext()){
System.out.println(itr.next());
}
返回“results::resultsList”;
//返回listServiceCorporateAmc;
}
}
这是我的results.html文件,它将显示控制器的结果
ServiceCorporateTeamCform
身份证件
客户ID
升级
由创建的服务请求
//我这里有点不对劲
身份证件
客户编号
升级
ServiceRequestCreatedBy
在thymeleaf中,我不能一次直接访问来自不同类或pojo的数据,我必须创建一个新的pojo,其中包含来自不同pojo的字段
谢谢大家
多谢各位
P.J.Meisch先生,谢谢您的评论那么问题出在哪里?当我检查时,我得到了这个错误,得到了500(内部服务器错误),并且我在控制台上得到了这个由以下原因引起的相应错误:org.springframework.expression.spel.SpelEvaluationException:EL1008E:在“java.lang.object[]类型的对象上找不到属性或字段“id”-也许不公开?