这里回答了类似的问题:Stripes 1.5 - any way to ask the system for a list of all 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 的列表。
有什么建议吗? (或者,至少,是否可以这样做?)
最好的问候,
最佳答案
好的。一段时间后,我找到了解决方案:使用 Stripes ResolverUtil
ResolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>();
resolver.findImplementations(ActionBean.class, "my.base.package");
Set<Class<? extends ActionBean>> beans = resolver.getClasses();
谢谢!
关于java - 如何在 contextInitialized() 中获取所有 actionbean 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7278686/