Search code examples
javaspringhibernatedisplaytag

Display tag pagination error on Spring + Hibernate MVC?


I am doing on an MVC project using spring, hibernate and I have a problem when navigating between pages in displat:table, it just show the first 10 items of the list (pagesize=10). When I navigate to other pages, it displays an url:http://localhost:8080/pinky_spring/clothes.jsp?d-1339940-p=7 and 404 error. Here is my definition for display:table

<display:table id="table_clothes" name="clothes" pagesize="10"
                               requestURI = "/clothes.jsp" 
                               keepStatus = "true" 
                               uid = "myTable" 
                               decorator="table_decorate.ClothesDecorate" >
    <display:column property="id" title=""/>
    <display:column title="no">
        <c:out value="${table_clothes_rowNum}"/>
    </display:column>
    <display:column property="name" />
    <display:column property="price" />
    <display:column property="dayUpdate" title="Update" sortable="true"/>
    <display:column property="pictures" title="Img"/>
    <display:column property="quantities" title="Qty"/>
</display:table>

And here is my controller

@Override
public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
    ModelAndView mv = new ModelAndView("clothes");
    List<Clothes> clothes = new ArrayList<>();
    try {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        clothes = session.createQuery("from Clothes").list();
        session.getTransaction();
        session.close();
    } catch (Exception e) {

    } finally {
        mv.addObject("clothes", clothes);
    }
    return mv;
}

Please help me, I am a newbie in java web!


Solution

  • The solution is very simple, I set requestURI="" and the problem is solved!