Retrieve data from database using Hibernate with Spring MVC. Error - “java.lang.NumberFormatException: For input string: ”

前端 未结 2 1319
逝去的感伤
逝去的感伤 2021-01-26 01:01

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

相关标签:
2条回答
  • 2021-01-26 01:44

    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.

    0 讨论(0)
  • 2021-01-26 01:56

    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.

    0 讨论(0)
提交回复
热议问题