Thymeleaf拿后台List的值

CustomerController.java

public class CustomerController {

    @Autowired
    CustomerRepository customerRepository;

    @RequestMapping("/")
    public String test(HttpSession session){
        List customers = customerRepository.findAll();
        session.setAttribute("customers",customers);
        return "test";
    }
}

CustomerRepository .java

public interface CustomerRepository extends JpaRepository {
	List findAll();
}

html

CustomerController.java

public class CustomerController {

    @Autowired
    CustomerRepository customerRepository;

    @RequestMapping("/")
    public String test(HttpSession session){
        Customer customers = customerRepository.findOne();
        session.setAttribute("customers",customers);
        return "test";
    }
}

CustomerRepository .java

public interface CustomerRepository extends JpaRepository {
	Customer findOne();
}

html

你可能感兴趣的:(Thymeleaf拿后台List的值)