在 Spring + Hibernate MVC 上显示标签分页错误?
Display tag pagination error on Spring + Hibernate MVC?
我正在使用 spring、hibernate 进行 MVC 项目,在 displat:table 中的页面之间导航时遇到问题,它只显示列表的前 10 个项目 (pagesize=10 ).当我导航到其他页面时,它显示 url:http://localhost:8080/pinky_spring/clothes.jsp?d-1339940-p=7 和 404 错误。这是我对 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>
这是我的控制器
@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;
}
请帮助我,我是 java 网络新手!
display:table标签的requestURI
应该指向控制器的URL。
解决方法很简单,我设置requestURI=""问题就解决了!
我正在使用 spring、hibernate 进行 MVC 项目,在 displat:table 中的页面之间导航时遇到问题,它只显示列表的前 10 个项目 (pagesize=10 ).当我导航到其他页面时,它显示 url:http://localhost:8080/pinky_spring/clothes.jsp?d-1339940-p=7 和 404 错误。这是我对 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>
这是我的控制器
@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;
}
请帮助我,我是 java 网络新手!
display:table标签的requestURI
应该指向控制器的URL。
解决方法很简单,我设置requestURI=""问题就解决了!