Parse to array to object thymeleaf

时间:2017-11-15 06:03:22

标签: javascript jquery arrays spring-boot thymeleaf

我无法解析这个并使用jquery做一个foreach javascript,我只是从控制器获取一个对象$ {Bills}

Bill [bill_id=1, date=2017-11-13, client=Client [phone=84859613, name=Justin, 
email=justinzu93@gmail.com], iva=13.0, adress=cartago, state_pay=pagado, 
method_pay=card, state=true, billDetails=[BillDetail [bill_detail_id=5, 
product=Product [product_id=1, name=Tamal, price=1500.0, state=true], unity=2, 
price=3000.0]]]


    <tr th:each="bill : ${bills}">
     <td th:text="${bill.bill_id}"></td>
     <td th:text="${bill.client.name}"></td>
     <td th:text="${#dates.format(bill.date, 'dd-MMMM-yyyy')}"></td>
     <td th:text="${#dates.format(bill.date, 'hh:mm:ss')}"></td>
     <td><button type="button" th:attr="data-whatever=${bill}" class="btn btn-primary" data-toggle="modal" data-target="#billDetail">Ver Detalles</button></td>
    </tr>

这是我的控制器只返回2个对象:

@Autowired
@Qualifier("billServiceImpl")
public BillService billServiceImpl;

private static final Log LOG = LogFactory.getLog(BillController.class);

private final String view = "bills";

@GetMapping("/admin/bills") 
public ModelAndView index(){

    User user = 

(User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    ModelAndView mvn = new ModelAndView();
    mvn.addObject("user",userServiceImpl.getOne(user.getUsername()));
    mvn.addObject("bills",billServiceImpl.getAll());
    LOG.info(billServiceImpl.getAll());
    mvn.setViewName(view);
    LOG.info("se ha ingresado a facturas");
    return mvn;

}

0 个答案:

没有答案