如何在 contextInitialized() 中获取所有 actionbean 类

发布于 2024-12-03 02:59:21 字数 1074 浏览 2 评论 0原文

这里回答了类似的问题:Stripes 1.5 - 有什么方法可以向系统询问所有 ActionBeans 的列表吗? 它似乎只在 actionbean 代码中起作用,即:当它实际收到请求时。
我想要的是列出 contextListener 代码中的所有 actionbean,例如 contextInitialized() 函数。发生错误:

net.sourceforge.stripes.exception.StripesRuntimeException: Something is trying to access the current Stripes configuration but the current request was never routed through the StripesFilter! As a result the appropriate Configuration object cannot be located. Please take a look at the exact URL in your browser's address bar and ensure that any requests to that URL will be filtered through the StripesFilter according to the filter mappings in your web.xml.
    at net.sourceforge.stripes.controller.StripesFilter.getConfiguration(StripesFilter.java:160)
    at net.sourceforge.stripes.util.CryptoUtil.encrypt(CryptoUtil.java:123) 

我的目的是自动初始化所​​有后来添加的插件类,而不需要在代码中的某个地方维护所有actionbean 的列表。 有什么建议吗? (或者,至少,是否可以这样做?)
此致,

A similar question is answered here: Stripes 1.5 - any way to ask the system for a list of all ActionBeans? it seems only work in an actionbean code, i.e: when it actually receives a request.

What I want is to list all actionbeans in contextListener code, for instance contextInitialized() function. Error happened:

net.sourceforge.stripes.exception.StripesRuntimeException: Something is trying to access the current Stripes configuration but the current request was never routed through the StripesFilter! As a result the appropriate Configuration object cannot be located. Please take a look at the exact URL in your browser's address bar and ensure that any requests to that URL will be filtered through the StripesFilter according to the filter mappings in your web.xml.
    at net.sourceforge.stripes.controller.StripesFilter.getConfiguration(StripesFilter.java:160)
    at net.sourceforge.stripes.util.CryptoUtil.encrypt(CryptoUtil.java:123) 

My purpose is to automatically initialize all the plug-in classes added later, without maintaining a list of all actionbeans somewhere in the code.
Any suggestion? (or, at least, is it possible to do so?)
Best Regards,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪恋 2024-12-10 02:59:21

好的。一段时间后,我找到了解决方案:使用 Stripes ResolverUtil

ResolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>();
resolver.findImplementations(ActionBean.class, "my.base.package");
Set<Class<? extends ActionBean>> beans = resolver.getClasses();

谢谢!

OK. After a while, I figured out the solution: using Stripes ResolverUtil

ResolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>();
resolver.findImplementations(ActionBean.class, "my.base.package");
Set<Class<? extends ActionBean>> beans = resolver.getClasses();

Thanks!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文