Home > Software design >  Not able to show ToDo list in JSP
Not able to show ToDo list in JSP

Time:10-10

I am new to spring boot and trying to create a simple ToDo Application using spring boot and JSP. I am trying to show the list of todo's in my JSP but it is not reflecting. I tried all the ways whereas on putting breakpoint in IntelliJ idea, I am able to see the list of todo's in my repo.

ToDoView.jsp

 <tbody>
                    <c:forEach items="${todolist}" var="todo">
                        <tr>
                            <td>${todo.description}</td>
                            <td><fmt:formatDate value="${todo.toDoDate}" pattern="dd/MM/yyyy" /></td>
                            <td><a type="button"  href="/update-todo?id=${todo.id}">Update</a>
                            <a type="button"  href="/delete-todo?id=${todo.id}">Delete</a></td>
                        </tr>
                    </c:forEach>
                </tbody>

HomeController.java

@GetMapping(value = "/list-todos")
public String toDoView(ModelMap m)
{
   List<ToDoList> allToDos = repo.findAll();

   m.put("todolist", allToDos);

   return "ToDoView";
}


ToDoRepo.java

public interface ToDoRepo extends JpaRepository<ToDoList, Integer>
{

}

ToDoList.java

package com.toDoApp.ToDoApp;

import javax.persistence.*;
import java.util.Date;

@Entity
public class ToDoList
{
    @Id
    private int id;
    private String description;
    private Date toDoDate;

    public ToDoList()
    {
        super();
    }

    public ToDoList(String description, Date toDoDate)
    {
        super();
        this.description = description;
        this.toDoDate = toDoDate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getToDoDate() {
        return toDoDate;
    }

    public void setToDoDate(Date toDoDate) {
        this.toDoDate = toDoDate;
    }
}

I tried all other ways but didn't able to find anything. Please help me out.

Thank You

CodePudding user response:

<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>

try adding jasper dependency

CodePudding user response:

Add the jasper Dependency

<dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-jasper</artifactId>
   <scope>provided</scope>
</dependency>

and change the first td tag to

"${todo.description}"
  • Related