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

前端 未结 2 1345
逝去的感伤
逝去的感伤 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条回答
  •  Happy的楠姐
    2021-01-26 01:56

    You have to set the criteria as parameters to get result in ItemsDAOImpl

    public List 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

     
    

    to

     
    

    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.

提交回复
热议问题