Iterate over List doesn't work - Spring MVC

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Iterate over List doesn't work - Spring MVC

jocasso
Hello,

I'm trying to iterate over a List and show it in a Table, but it doesn't work.

Controller:





@RequestMapping(value="/home")
        public String home(Model model) throws IOException{
                List<OrderNotify> notifications = new ArrayList<OrderNotify>();
                for(int i =0; i < 10; i++) {
                        OrderNotify notification = new OrderNotify("1", "2", "3", "4");
                        notifications.add(notification);
                model.addAttribute("notifications", notifications);
                return "home";

        }
 

home.jsp :

< table id="handle" style=" margin:auto" >

    < tr>
        < th>Bestellnummer </th>
        < th>Datum < /th>
        < th>Status < /th>
         < th>Handlung erforderlich < /th>
    </tr>
    < tr th:each="notify : ${notifications}">
        < td th:text="${notify.orderid}"> < /td>
        < td th:text="${notify.date}">< /td>
        < td th:text="${notify.status}">< /td>
        < td th:text="${notify.handle}"> < /td>
    </tr>



< /table>




 OrderNotify  class:




public class OrderNotify {

    public String orderid;
    public String date;
    public String status;
    public String handle;

    public OrderNotify(String orderid, String date, String status, String handle) {
        this.orderid = orderid;
        this.date = date;
        this.status = status;
        this.handle = handle;
    }

    public List<String> getAll(){
        return null;
    }

    public String getOrderid() {
        return orderid;
    }

    public void setOrderid(String orderid) {
        this.orderid = orderid;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getHandle() {
        return handle;
    }

    public void setHandle(String handle) {
        this.handle = handle;
    }

Thanks for your help!!



Reply | Threaded
Open this post in threaded view
|

Re: Iterate over List doesn't work - Spring MVC

redfox26
home.jsp?

is supposed to be home.html....