这里回答了一个类似的问题: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/

10-11 01:00