JSR303 Bean驗證實現Hibernate-Validator(4.1.0)提供org.hibernate.validator.constraints.ScriptAssert
註釋。驗證@Script插入並訪問靜態方法
我得到它的工作調用非靜態方法。
@ScriptAssert(script="_this.isComplexSubValid(_this.attributeA,_this.attributeB)",
lang = "javascript")
...
public boolean isComplexSubValid(Object a, Object b)...
但現在我想外部化isComplexSubValid
作爲一個靜態方法來重複使用在不同的班級。但是我沒有得到JavaScript驗證器的靜態調用。
@ScriptAssert(script="ComplexValidation.isComplexSubValid(_this.attributeA,_this.attributeB)",
lang = "javascript")
public static boolean isComplexSubValid(Object a, Object b)...
拋出:
的isValid通話過程中意外的異常: org.hibernate.validator.engine.ConstraintTree.validateSingleConstraint(ConstraintTree.java:156) org.hibernate.validator.engine.ConstraintTree .validateConstraints(ConstraintTree.java:140) org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:121) org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:327) 有機hibernate.validator.engine.Val idatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:273) org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:256) org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:210) 組織.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119) org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:86) org.springframework.validation.DataBinder.validate(DataBinder.java :692) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:807) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:359) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) org.springframework .web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:571) javax.servlet。 http.HttpS ervlet.service(HttpServlet.java:640) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache .catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter的.java:76) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.springframework.security。 web.FilterChainProxy $ VIRTUA lFilterChain.doFilter(FilterChainProxy.java:368) org.springframework.security.web.access.intercept。FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(的FilterChainProxy。 Java的:380) org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework .security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework.security.web.authentication.Anon ymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java: 54) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) org.springframework.security .web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177) org.spring framework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(的FilterChainProxy。 Java的:380) org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:380) org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy.java:167) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) de.humanfork。 security.crsf.IdempotentCsrfPreventionFilter.doFilter(IdempotentCsrfPreventionFilter.java:99) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java: 206) org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:74) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:113) 組織。 springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain。的java:206) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 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:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 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:298) org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:859) org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:588) org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489 ) java.lang.Thread.run(Thread.java:662)
所以我的問題是如何調用腳本標記內的靜態方法?
請不要告訴我,我可以實現我的驗證程序,而不是使用@Script標記。