我正在尝试在Eclipse STS下的我的(Spring MVC / Hibernate / MySQL)项目中实现Spring Pagination,所以我在[A Pagination Technique Using Spring] [1]中遵循了这个例子,因为我发现它在这里推荐在Stackoverflow中对类似问题的许多答案。现在我有一个问题和一个问题:
问题:如何将分页标记文件导入到我的项目中?特别是我在项目WEB-INF文件夹下看不到任何Tag文件夹?
问题:我每次尝试构建/运行项目时都会遇到一些麻烦我会收到错误:
java.lang.ClassNotFoundException:org.springframework.web.context.support.StandardServletEnvironment 在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) 在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) 在org.springframework.web.servlet.HttpServletBean。(HttpServletBean.java:90) 在org.springframework.web.servlet.FrameworkServlet。(FrameworkServlet.java:211) 在org.springframework.web.servlet.DispatcherServlet。(DispatcherServlet.java:303) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 在java.lang.Class.newInstance0(Class.java:357) 在java.lang.Class.newInstance(Class.java:310) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:138) 在org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144) 在org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088) 在org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) 在org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114) 在org.apache.catalina.startup.HostConfig $ DeployDirectory.run(HostConfig.java:1672) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:439) at java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303) 在java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:918) 在java.lang.Thread.run(Thread.java:662)
我已仔细检查了我的代码,但我不知道可能出现的问题。那么有人可以告诉我我可能做错了吗?
控制器:
public String listVolDisc(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
List searchResults = ivoldiscservice.getAllVolDisc();
PagedListHolder pagedListHolder = new PagedListHolder(searchResults);
int page = ServletRequestUtils.getIntParameter(request, "p", 0);
pagedListHolder.setPage(page);
int pageSize = 10;
pagedListHolder.setPageSize(pageSize);
model.addAttribute("pagedListHolder", pagedListHolder);
return "VolDiscount";
}
JSP:
<c:url value="/paging.do" var="pagedLink">
<c:param name="action" value="list"/>
<c:param name="p" value="~"/>
</c:url>
<div class="section">
<h2 class="section_title">Volume Discounts</h2>
<tg:paging pagedListHolder="${pagedListHolder}" pagedLink="${pagedLink}"/>
<div class="table">
<div class="table_header">
<div class="cell">ID</div>
<div class="cell">From</div>
<div class="cell">To</div>
<div class="cell">Discount</div>
</div>
<%-- <c:forEach var="voldiscount" items="${voldiscountList}"> --%>
<c:forEach var="voldiscount" items="${pagedListHolder}">
<div class="table_row">
<div class="cell important">${voldiscount.id}</div>
<div class="cell">${voldiscount.rangeStarts}</div>
<div class="cell">${voldiscount.rangeEnds}</div>
<div class="cell">${voldiscount.discount}</div>
</div>
</c:forEach>
</div><!-- .table -->
<tg:paging pagedListHolder="${pagedListHolder}" pagedLink="${pagedLink}"/>
</div><!-- .section -->
DAO:
public List<VolumeDiscount> getAllVolDisc() {
return sessionfactory.getCurrentSession().createQuery("from VolumeDiscount v").list();
}
感谢您的时间