标签:
如下报错:
16:22:05.566 [http-nio-80-exec-12] ERROR 500.jsp - No enum constant org.springside.modules.persistence.SearchFilter.Operator.GE
java.lang.IllegalArgumentException: No enum constant org.springside.modules.persistence.SearchFilter.Operator.GE
at java.lang.Enum.valueOf(Enum.java:238) ~[na:1.8.0_25]
at org.springside.modules.persistence.SearchFilter$Operator.valueOf(SearchFilter.java:17) ~[SearchFilter$Operator.class:4.3.0-SNAPSHOT]
at org.springside.modules.persistence.SearchFilter.parse(SearchFilter.java:51) ~[SearchFilter.class:4.3.0-SNAPSHOT]
at com.zzy.flowers.service.BaseService.createSpecification(BaseService.java:50) ~[BaseService.class:na]
at com.zzy.flowers.service.seedlings.SeedlingsService.listSeedlings(SeedlingsService.java:47) ~[SeedlingsService.class:na]
at com.zzy.flowers.service.seedlings.SeedlingsService$$FastClassBySpringCGLIB$$5b7ef2fc.invoke(<generated>) ~[ReflectUtils.class:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[MethodProxy.class:4.0.5.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708) ~[CglibAopProxy$CglibMethodInvocation.class:4.0.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[ReflectiveMethodInvocation.class:4.0.5.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) ~[TransactionInterceptor$1.class:4.0.5.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) ~[TransactionAspectSupport.class:4.0.5.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) ~[TransactionInterceptor.class:4.0.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[ReflectiveMethodInvocation.class:4.0.5.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644) ~[CglibAopProxy$DynamicAdvisedInterceptor.class:4.0.5.RELEASE]
at com.zzy.flowers.service.seedlings.SeedlingsService$$EnhancerBySpringCGLIB$$e0595871.listSeedlings(<generated>) ~[ReflectUtils.class:na]
at com.zzy.flowers.controller.seedlings.SeedlingsController.listSeedlings(SeedlingsController.java:196) ~[SeedlingsController.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) ~[InvocableHandlerMethod.class:4.0.5.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) ~[InvocableHandlerMethod.class:4.0.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[ServletInvocableHandlerMethod.class:4.0.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) ~[RequestMappingHandlerAdapter.class:4.0.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689) ~[RequestMappingHandlerAdapter.class:4.0.5.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) ~[AbstractHandlerMethodAdapter.class:4.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938) [DispatcherServlet.class:4.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) [DispatcherServlet.class:4.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) [FrameworkServlet.class:4.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) [FrameworkServlet.class:4.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) [servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) [FrameworkServlet.class:4.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301) [catalina.jar:8.0.8]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.8]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.8]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.8]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.8]
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) [SiteMeshFilter.class:na]
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) [SiteMeshFilter.class:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.8]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.8]
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) [ProxiedFilterChain.class:1.2.3]
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) [AdviceFilter.class:1.2.3]
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) [AdviceFilter.class:1.2.3]
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) [OncePerRequestFilter.class:1.2.3]
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) [ProxiedFilterChain.class:1.2.3]
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) [AbstractShiroFilter.class:1.2.3]
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) [AbstractShiroFilter$1.class:1.2.3]
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [SubjectCallable.class:1.2.3]
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [SubjectCallable.class:1.2.3]
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) [DelegatingSubject.class:1.2.3]
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) [AbstractShiroFilter.class:1.2.3]
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) [OncePerRequestFilter.class:1.2.3]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) [DelegatingFilterProxy.class:4.0.5.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) [DelegatingFilterProxy.class:4.0.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.8]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.8]
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:177) [OpenEntityManagerInViewFilter.class:4.0.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [OncePerRequestFilter.class:4.0.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.8]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.8]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [CharacterEncodingFilter.class:4.0.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [OncePerRequestFilter.class:4.0.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.8]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.8]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [catalina.jar:8.0.8]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.8]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) [catalina.jar:8.0.8]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136) [catalina.jar:8.0.8]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:78) [catalina.jar:8.0.8]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) [catalina.jar:8.0.8]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.8]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526) [catalina.jar:8.0.8]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1033) [tomcat-coyote.jar:8.0.8]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652) [tomcat-coyote.jar:8.0.8]
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) [tomcat-coyote.jar:8.0.8]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566) [tomcat-coyote.jar:8.0.8]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523) [tomcat-coyote.jar:8.0.8]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_25]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.8]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
很明显,不支持的操作符GE,查看我们的代码:
<li><label>信息:</label> <input type="text"
value="${searchParamsTemp['GTE_seedlingsbaseinfo.diameter']}"
size="15" name="search_GE_seedlingsbaseinfo.diameter"
id="diameter"></li>
<li><label>信息:</label> <input type="text"
value="${searchParamsTemp['GTE_seedlingsbaseinfo.mijing']}"
size="15" name="search_GE_seedlingsbaseinfo.mijing" id="mijing"></li>
<li><label>信息:</label> <input type="text"
value="${searchParamsTemp['GTE_seedlingsbaseinfo.height']}"
size="15" name="search_GE_seedlingsbaseinfo.height" id="height"></li>
<li><label>信息:</label> <input type="text"
value="${searchParamsTemp['GTE_seedlingsbaseinfo.crown']}"
size="15" name="search_GE_seedlingsbaseinfo.crown" id="crown"></li>
<li><label>信息:</label> <input type="text"
value="${searchParamsTemp['GTE_seedlingsbaseinfo.offbarHeight']}"
size="15" name="search_GE_seedlingsbaseinfo.offbarHeight"
id="offbarHeight"></li>
,查看SearchFilter
源码:
<strong><span style="color:#dcdcdc;">package org.springside.modules.persistence;
import java.util.Map;
import java.util.Map.Entry;
</span>import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Maps;
public class SearchFilter {
public enum Operator {
EQ, LIKE, GT, LT, GTE, LTE
}
public String fieldName;
public Object value;
public Operator operator;
public SearchFilter(String fieldName, Operator operator, Object value) {
this.fieldName = fieldName;
this.value = value;
this.operator = operator;
}
/**
* searchParams中key的格式为OPERATOR_FIELDNAME
*/
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
Map<String, SearchFilter> filters = Maps.newHashMap();
for (Entry<String, Object> entry : searchParams.entrySet()) {
// 过滤掉空值
String key = entry.getKey();
Object value = entry.getValue();
if (StringUtils.isBlank((String) value)) {
continue;
}
// 拆分operator与filedAttribute
String[] names = StringUtils.split(key, "_");
if (names.length != 2) {
throw new IllegalArgumentException(key + " is not a valid search filter name");
}
String filedName = names[1];
Operator operator = Operator.valueOf(names[0]);
// 创建searchFilter
SearchFilter filter = new SearchFilter(filedName, operator, value);
filters.put(key, filter);
}
return filters;
}
}</strong><span style="color:#dcdcdc;">
</span>
来源:http://code.taobao.org/p/guanglai/src/trunk/springside4/modules/core/src/main/java/org/springside/modules/persistence/SearchFilter.java
可以看到仅支持六种操作:EQ,
LIKE, GT, LT, GTE, LTE
修改程序name命名即可!注意后台Controller保持一致!
Springside动态组合条件搜索:No enum constant org.springside.modules.persistence.SearchFilter.Operator.GE
标签:
原文地址:http://blog.csdn.net/up1up2up3/article/details/42319759