如何从spring

时间:2015-12-03 11:16:46

标签: spring-mvc spring-boot thymeleaf

我写了一个如下的存储库:

@Query("select c.custName,b.ansType from Customer c,Custype b where c.custype_id=b.id")

public List<Customer> findAllByQueryDescription();

其中custName和ansType属性属于实体Customer和Custype。

控制器方法:

        @Autowired CustomerRepository customerRepository; @RequestMapping(value="/customer") 
        public String showCustomer(Model model) { 
           List<Customer> custlist=customerRepository.findAllByQueryDescription(); 
           model.addAttribute("custList",custlist); 
           return "home";
        }

现在,我想使用thymeleaf为我的spring boot mvc项目显示两个表的数据表中的数据。在我看来,我添加了如下代码

<tr th:each="${cust:custList}">
  <td th:text="${cust.custName}"></td>
</tr>

但是在浏览器中显示错误,例如找不到cust.custName。

我的问题是如何从多个表中获取数据并显示在表中

0 个答案:

没有答案