gpt4 book ai didi

grails - 如何在Grails 3中使用过滤器而不是拦截器?

转载 作者:行者123 更新时间:2023-12-02 14:13:54 24 4
gpt4 key购买 nike

Grails 3在Interceptors vs Filters下的文档说:
In versions of Grails prior to Grails 3.0, Grails supported the notion of filters. These are still supported for backwards compatibility but are considered deprecated.
我有一个很大的Grails 2.5应用程序迁移到Grails 3.2,并希望继续使用过滤器。

如何使过滤器在Grails 3. *中工作?

按照[http://docs.grails.org/latest/guide/upgrading.html],我添加了compile 'org.grails:grails-plugin-filters:3.0.12'并将过滤器类从grails-app/conf移到grails-app/controllers,但是随后出现以下异常:

java.lang.NullPointerException: null
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1337)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197)
at java.beans.Introspector.getBeanInfo(Introspector.java:426)
at java.beans.Introspector.getBeanInfo(Introspector.java:173)
at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3318)
at java.security.AccessController.doPrivileged(Native Method)
at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3316)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3293)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:260)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:302)
at org.grails.plugins.web.filters.FilterToHandlerAdapter.$getStaticMetaClass(FilterToHandlerAdapter.groovy)
at org.grails.plugins.web.filters.FilterToHandlerAdapter.<init>(FilterToHandlerAdapter.groovy:63)
at org.grails.plugins.web.filters.FiltersGrailsPlugin.reloadFilters(FiltersGrailsPlugin.groovy:195)
at org.grails.plugins.web.filters.FiltersGrailsPlugin.doWithApplicationContext(FiltersGrailsPlugin.groovy:72)
at org.grails.plugins.DefaultGrailsPlugin.doWithApplicationContext(DefaultGrailsPlugin.java:523)
at org.grails.plugins.AbstractGrailsPluginManager.doPostProcessing(AbstractGrailsPluginManager.java:224)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:246)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:372)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
at grails.boot.GrailsApp.run(GrailsApp.groovy:388)
at grails.boot.GrailsApp.run(GrailsApp.groovy:375)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at app6.Application.main(Application.groovy:8)

最佳答案

相同的文档sez:

These are still supported



这意味着您仍然可以按原样使用它们。弃用意味着您应该开始考虑将其替换为拦截器。

关于grails - 如何在Grails 3中使用过滤器而不是拦截器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43602745/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com