I\'m trying to create a simple webapp with a search Page. I have implemented CRUD part and it\'s working. I\'m new to coding. Having trouble with the search option. Error - \"ja
It was simple syntax issue at the end. @saifulislamplabon Answer fixed my Hibernate part and Error -" java.lang.NumberFormatException For input string: "ISBN" was causing because my JSP page had an error with <c:forEach
tag. It was caused by the white space between <% @page
. I corrected it to <%@page contentType="text/html" pageEncoding="UTF-8"%>
and everything works fine now. Thanks for the support.
You have to set the criteria as parameters to get result in ItemsDAOImpl
public List<Items> searchitems(String category_id, String publsiher_id) {
return sessionFactory.getCurrentSession().createQuery("from Items E where E.category_id = :category_id AND E.publisher_id= :publisher_id")
.setParameter("category_id", category_id)
.setParameter("publisher_id", publsiher_id)
.list();
}
In your searchResult.jsp
you are iterating over listItems2
but you added is attribute as items
in your controller.
Change
<c:forEach var="items" items="${listItems2}">
to
<c:forEach var="items" items="${items}">
On an other note, please name the entities properly. Entity name should be Item
and collection name should Items
. But do that later, first try to fix the current problem.