org.thymeleaf.exceptions.TemplateProcessingException:评估SpringEL表达式的异常:“ServiceAmc.id”(结果:30)

时间:2017-04-21 18:16:16

标签: javascript java

这是我的SerCorAmc.html文件,其中我有一个按钮点击按钮后showResult()方法将调用它将调用包含url的控制器,如acquireServiceCorporateAmcFormDetailsAMC。

            <!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>

1 个答案:

答案 0 :(得分:0)

在百里香中,我无法一次直接访问不同类或pojo的数据,我必须创建一个包含来自不同pojo的字段的新pojo。

谢谢EveryOne

谢谢你  P.J.Meisch先生,您的意见