3
Good afternoon. I’m working on Repository and Spring MVC. I have an interface, Storedao that looks like this.
public interface StoreOrderDAO extends JpaRepository<StoreOrder, String>{
List<StoreOrder> findByUser_id(String user_id);
@Query("SELECT pedido FROM StoreOrder as pedido WHERE pedido.id=:orderId AND pedido.user.id=:userId")
public StoreOrder getById(@Param("orderId") String order_id, @Param("userId") String user_id);
@Query("FROM StoreOrder s INNER JOIN s.user u WHERE u.fullname LIKE %:name%")
public Page<StoreOrder> findByName(@Param("name") String name, Pageable pageable);
}
My Storeorderserviceimpl is like this
public Page<StoreOrder> getStoreOrderSearch(Integer pageNumber, String name) {
PageRequest request = new PageRequest(pageNumber - 1, PAGE_SIZE, Sort.Direction.ASC, "createdon");
return storeOrderDAO.findByName(name, request);
}
And the Storeordercontroller
@RequestMapping(value = {searchPath} , method = RequestMethod.GET)
public String search(@RequestParam(value = "q", required = false) String name, ModelMap modelMap) {
Integer pageNumber = 1;
Page<StoreOrder> page = storeOrderService.getStoreOrderSearch(pageNumber, name);
int current = page.getNumber() + 1;
int begin = Math.max(1, current - 5);
int end = Math.min(begin + 10, page.getTotalPages());
List<StoreOrder> orders = page.getContent();
modelMap.addAttribute("url", getURL(defaultPath));
modelMap.addAttribute("orders", orders);
modelMap.addAttribute("pages", page);
modelMap.addAttribute("beginIndex", begin);
modelMap.addAttribute("endIndex", end);
modelMap.addAttribute("currentIndex", current);
return listView;
}
list.jsp
<c:forEach items="${orders}" var="row">
<tr>
<td><xphub:datetime value="${row.createdon}" /></td>
<td>${row.totalamount}</td>
<td>${row.user.fullname}</td>
<td class="text-center"><xphub:form_actions id="${row.id}" view="true" cancel="true" /></td>
</tr>
If I do a search for the system search field the following error happens:
java.lang.NumberFormatException: For input string: "createdon"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
java.lang.Integer.parseInt(Integer.java:580)
java.lang.Integer.parseInt(Integer.java:615)
javax.el.ArrayELResolver.coerce(ArrayELResolver.java:151)
javax.el.ArrayELResolver.getValue(ArrayELResolver.java:64)
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
org.apache.el.parser.AstValue.getValue(AstValue.java:167)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:936)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp._jspx_meth_xphub_005fdatetime_005f0(list_jsp.java:458)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp._jspx_meth_c_005fforEach_005f0(list_jsp.java:414)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp._jspx_meth_c_005fif_005f0(list_jsp.java:260)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp.access$3(list_jsp.java:221)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp$Helper.invoke1(list_jsp.java:599)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp$Helper.invoke(list_jsp.java:627)
org.apache.tiles.request.jsp.autotag.JspModelBody.evaluate(JspModelBody.java:62)
org.apache.tiles.autotag.core.runtime.AbstractModelBody.evaluateAsString(AbstractModelBody.java:59)
org.apache.tiles.template.PutAttributeModel.execute(PutAttributeModel.java:96)
org.apache.tiles.jsp.taglib.PutAttributeTag.doTag(PutAttributeTag.java:226)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp._jspx_meth_tiles_005fputAttribute_005f0(list_jsp.java:175)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp.access$0(list_jsp.java:163)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp$Helper.invoke0(list_jsp.java:577)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp$Helper.invoke(list_jsp.java:624)
org.apache.tiles.request.jsp.autotag.JspModelBody.evaluate(JspModelBody.java:62)
org.apache.tiles.autotag.core.runtime.AbstractModelBody.evaluateWithoutWriting(AbstractModelBody.java:77)
org.apache.tiles.template.InsertDefinitionModel.execute(InsertDefinitionModel.java:97)
org.apache.tiles.jsp.taglib.InsertDefinitionTag.doTag(InsertDefinitionTag.java:254)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp._jspx_meth_tiles_005finsertDefinition_005f0(list_jsp.java:158)
org.apache.jsp.presentation.views.modules.admin.store.order.list_jsp._jspService(list_jsp.java:126)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
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.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.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.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
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)
Except that if I have the database data listed without going through the search field, it returns everything without error, this error happens only when I filter through the search field.
What is this taglib you’re using? xphub? Because by stacktrace the error is in the compilation of some jsp that is using the value "createdon", some conversion attempt.
– Rudge