Cannot solve the problem javax.el.PropertyNotFoundException: Property [content] not found on type [java.lang.String]

I've read the same problem solutions, but it didn't helped me. there is a part of my Bean class with good written getter:

@Entity
@Table(name = "notes")
public class Note {
    @Id
    @GeneratedValue (strategy = GenerationType.IDENTITY)
    @Column (name = "id")
    private int id;    
    @Column (name = "content")
    private String content;


    public Note() {
    }

    public Note(String title, String content, GregorianCalendar date, boolean done) {
        this.title = title;
        this.content = content;
        this.date = date;
        this.done = done;
    }

    public int getId() {
        return id;
    }

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

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    } 
}

Using debug mode i can see, that i've got my ArrayList of notes from dataBase. It means, that connection is good. there is a code from servlet:

public static final String OUTPUT_LIST = "List For Pager";

// other code, not nessesary for showing  

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            Integer pageNumber =  (Integer) req.getAttribute(PAGE_NUMBER);
            if(pageNumber==null) pageNumber = 1;
            ArrayList<Note> result = new ArrayList<Note>();
            ArrayList<Note> notes = DaoDriver.getActualNotesHandler().getNotesList();
            //iteration method for filling result
            fillListForPage(pageNumber,notes,result);
            req.setAttribute(OUTPUT_LIST,result);
            RequestDispatcher requestDispatcher = req.getRequestDispatcher("/index_test.jsp");
            requestDispatcher.forward(req,resp);

There is a place, where i call my list from jsp:

<c:forEach var="note" items="${MainServlet.OUTPUT_LIST}">

      <div class="row" padding="5" >
        <div class="card-deck">
          <div class="card">
            <div class="card-header">Title1</div>
            <div class="card-body"><p>${note.content}</p></div>
            <div class="card-footer">
              <input type="checkbox" class="Done">
              <label>Done</label>
              <button>Edit Note</button>
            </div>
          </div>

    </c:forEach>

i have additional problem here, that can crash my application. I have the same situation, like in this question: JPA Cannot resolve column/IntelliJ

but i have my data associated and quick fix doesn't resolve this problem.

what is wrong with my code?

1 answer

  • answered 2018-09-24 03:22 huy

    Try changing ${MainServlet.OUTPUT_LIST} to ${requestScope.OUTPUT_LIST}

    <c:forEach var="note" items="${requestScope.OUTPUT_LIST}">