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

标签 java stripes

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

相关文章:

java - 如何使用 AndroidPlot 在 Lollipop 上正确调整绘图大小?

java - JUnit4 + Eclipse "An internal error occurred during Launching"

java - Stripes 忽略提交按钮事件

javascript - 更好的解决方案或替换window.unload

java - 条纹 - 重定向,使 session 过期

java - 使用textureRegion绘图

java - Java中的表达式评估

java - 用 Java 或 Python 从我的网络摄像头捕获单个图像

java - stripes 是一个占用空间很小的框架,可以在企业环境中制作小型 Web 应用程序吗?

java - Stripes Framework 中根据 Language 加载文件