我正在尝试在我的项目中实现Datatables spring。
在RoleController.java
档案
@Controller
public class RoleController {
@RequestMapping(value = "/masterRole")
public ModelAndView about() {
RoleDAO dao = new RoleDAOImpl();
List<Role> list = dao.list();
ModelAndView model = new ModelAndView();
model.addObject("list",list);
model.setViewName("roleTile");
return model;
}
}
在tiles.xml
档案
<definition name="roleTile" extends="base.definition" >
<put-attribute name="title" value="DAM Role Master" />
<put-attribute name="body" value="/WEB-INF/pages/viewRole.jsp" />
<put-attribute name="menuselection" value="master" />
</definition>
在viewRole.jsp
档案
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
<datatables:table id="roles" data="${list}" row="role" cssClass="table table-striped">
<datatables:column title="Id">
<c:out value="${role.roleId}"></c:out>
</datatables:column>
<datatables:column title="Role">
<c:out value="${role.role}"></c:out>
</datatables:column>
</datatables:table>
我收到以下错误
显示java.lang.NullPointerException 在com.github.dandelion.datatables.core.configuration.ConfigurationStore.getPrototype(ConfigurationStore.java:82) 在com.github.dandelion.datatables.core.configuration.TableConfiguration.getInstance(TableConfiguration.java:117) 在com.github.dandelion.datatables.core.html.HtmlTable。(HtmlTable.java:76) 在com.github.dandelion.datatables.jsp.tag.TableTag.doStartTag(TableTag.java:91) at org.apache.jsp.WEB_002dINF.pages.viewRole_jsp._jspService(viewRole_jsp.java:78) 在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) 在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) 在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) 在org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535) 在org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472) 在org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968) at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:638) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:632) 在org.apache.tiles.request.jsp.JspRequest.doInclude(JspRequest.java:123) 在org.apache.tiles.request.AbstractViewRequest.dispatch(AbstractViewRequest.java:47) 在org.apache.tiles.request.render.DispatchRenderer.render(DispatchRenderer.java:47) 在org.apache.tiles.request.render.ChainedDelegateRenderer.render(ChainedDelegateRenderer.java:68) 在org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:259) at org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:188) at org.apache.tiles.template.InsertAttributeModel.execute(InsertAttributeModel.java:132) at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:299) at org.apache.jsp.WEB_002dINF.pages.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f4(layout_jsp.java:222) 在org.apache.jsp.WEB_002dINF.pages.layout_jsp._jspService(layout_jsp.java:95) 在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) 在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) 在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) 在org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) 在org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) 在org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) 在org.apache.tiles.request.servlet.ServletRequest.forward(ServletRequest.java:265) 在org.apache.tiles.request.servlet.ServletRequest.doForward(ServletRequest.java:228) at org.apache.tiles.request.AbstractClientRequest.dispatch(AbstractClientRequest.java:57) 在org.apache.tiles.request.render.DispatchRenderer.render(DispatchRenderer.java:47) 在org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:259) 在org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:397) 在org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:238) 在org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:221) 在org.apache.tiles.renderer.DefinitionRenderer.render(DefinitionRenderer.java:59) 在org.springframework.web.servlet.view.tiles3.TilesView.renderMergedOutputModel(TilesView.java:114) 在org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:267) 在org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1221) 在org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1005) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:952) 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) 在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) 在org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:85) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342) 在org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 在org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 在org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) 在org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) 在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:583) 在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:447) 在java.lang.Thread.run(Thread.java:744)
我是Datatables的新手。请帮帮我。
还邀请链接与Spring 4一起使用hibernate和tiles逐步集成Datatbles。
答案 0 :(得分:2)
错误表示datatables
的web.xml
中缺少配置
第1步:在web.xml
<!-- Dandelion-Datatables servlet definition -->
<servlet>
<servlet-name>datatablesController</servlet-name>
<servlet-class>com.github.dandelion.datatables.extras.servlet2.servlet.DatatablesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>datatablesController</servlet-name>
<url-pattern>/datatablesController/*</url-pattern>
</servlet-mapping>
<!-- Dandelion servlet definition and mapping -->
<servlet>
<servlet-name>dandelionServlet</servlet-name>
<servlet-class>com.github.dandelion.core.web.DandelionServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dandelionServlet</servlet-name>
<url-pattern>/dandelion-assets/*</url-pattern>
</servlet-mapping>
<!-- Dandelion filter definition and mapping -->
<filter>
<filter-name>dandelionFilter</filter-name>
<filter-class>com.github.dandelion.core.web.DandelionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>dandelionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
第2步:添加必需的jar文件
公地BeanUtils的-1.9.1.jar
蒲公英核心0.10.0.jar
数据表芯,0.10.0.jar
数据表,JSP的0.10.0.jar
数据表,servlet2-0.9.3.jar
ehcache的核心 - 2.6.9.jar
杰克逊的注解-2.2.3.jar
杰克逊核心2.2.3.jar
杰克逊 - 数据绑定-2.2.3.jar
JSON-简单1.1.1.jar
JSTL-api.jar文件
JSTL-impl.jar中
的log4j-1.2.16.jar
其他罐子:春季罐子+瓷砖罐子+ hibernate罐子
注意:我根据项目需要调整了罐子,你可以根据需要添加罐子。
答案 1 :(得分:1)
您的问题可能来自web.xml
中缺少某些声明。已在forum中报告,并且v0.10.1中将提供修复程序,以警告用户有关缺少声明的内容。
关于 datatables-servlet2 额外的一点说明。 从v0.10.0开始,它不再存在。所以我建议你删除它并避免0.9.3和0.10.0可能的依赖问题。
web.xml
中的新声明如下:
<!-- Dandelion-Datatables filter used for basic export -->
<filter>
<filter-name>datatables</filter-name>
<filter-class>com.github.dandelion.datatables.core.web.filter.DatatablesFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>datatables</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
文档的export section已更新,以反映最后的更改。