Struts 1.3 的 Struts 操作调用框架

发布于 2024-09-28 23:41:52 字数 2510 浏览 0 评论 0原文

我正在尝试集成 SAIF 插件来拦截我的 struts 操作。我从中学习 http://struts.sourceforge.net/saif/index.html

我写过像这样的配置: struts-config.xml

<plug-in className="net.sf.struts.saif.SAIFPlugin">
    <set-property property="interceptor-config" value="/WEB-INF/interceptor-config.xml" />
</plug-in>

拦截器-config.xml

<interceptor-config>
 <interceptor name="componentInterceptor" type="net.sf.struts.saif.ComponentInterceptor"/>
 <interceptor name="testInterceptor" type="net.sf.struts.saif.TestInterceptor"/>

 <default-interceptors>
  <interceptor name="componentInterceptor"/>
 </default-interceptors>

 <action type="org.apache.struts.webapp.example.EditRegistrationAction">
  <interceptor name="testInterceptor"/>
 </action>
</interceptor-config> 

我收到这样的错误:

javax.servlet.UnavailableException: Specified RequestProcessor not compatible with saif.
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

你能帮我解决这个问题吗?

I'm trying to integration SAIF plugin to intercept my struts action. I learn from
http://struts.sourceforge.net/saif/index.html

I've write configuration like this:
struts-config.xml

<plug-in className="net.sf.struts.saif.SAIFPlugin">
    <set-property property="interceptor-config" value="/WEB-INF/interceptor-config.xml" />
</plug-in>

interceptor-config.xml

<interceptor-config>
 <interceptor name="componentInterceptor" type="net.sf.struts.saif.ComponentInterceptor"/>
 <interceptor name="testInterceptor" type="net.sf.struts.saif.TestInterceptor"/>

 <default-interceptors>
  <interceptor name="componentInterceptor"/>
 </default-interceptors>

 <action type="org.apache.struts.webapp.example.EditRegistrationAction">
  <interceptor name="testInterceptor"/>
 </action>
</interceptor-config> 

I got error like this:

javax.servlet.UnavailableException: Specified RequestProcessor not compatible with saif.
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

can you help me to solve this problem ?

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

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

发布评论

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

评论(2

£冰雨忧蓝° 2024-10-05 23:41:52

引用 struts 用户邮件列表中的此消息

SAIF不太可能成功
使用默认的 S1.3 配置
请求处理器不同——你
可以尝试使用旧的请求
处理器(如果您的应用程序没有)
依赖它。

AFAICT SAIF 无法与
标准以外的任何东西(旧)
请求处理器,但它可能是
可以将其破解,这样就可以了。

Quoting this message from the struts users mailing list:

It's unlikely that SAIF would work
with the default S1.3 config since the
request processor is different--you
could try using the old request
processor if your application doesn't
rely on it.

AFAICT SAIF wouldn't work with
anything other than the standard (old)
request processor, but it might be
possible to hack it up so it would.

半暖夏伤 2024-10-05 23:41:52

我以前没有使用过 Struts 操作调用框架,但 Tiles 中的异常消息对我来说很熟悉。 Tiles 抛出这样的消息: Specified RequestProcessor 与 TilesRequestProcessor 不兼容 所以我认为除了消息的熟悉性(在您的情况下 Specified RequestProcessor 与 saif 不兼容)还有也有可能原因相同。

这是一篇文章,修复了 Tiles 插件上的这个问题。可能对你有帮助。

当 Struts Servlet 初始化时,它会初始化所有插件。该消息应该来自插件的 init 方法,如果它与 Tiles 相同,则使用 Class.isAssignableFrom 应该是原因。

编辑:查找SAIF插件的源代码并在其中找到了这个:

protected void initRequestProcessorClass(ActionServlet servlet, ModuleConfig config) throws ServletException {
  .........
  .........
  ControllerConfig ctrlConfig = config.getControllerConfig();
  String configProcessorClassname = ctrlConfig.getProcessorClass();
  .........
  .........
  // Check if specified request processor is compatible with saif.
  try {
    Class saifProcessorClass = SAIFRequestProcessor.class;
    Class saifTilesProcessorClass = SAIFTilesRequestProcessor.class;
    Class configProcessorClass = Class.forName(configProcessorClassname);
    if (!saifProcessorClass.isAssignableFrom(configProcessorClass)
       && !saifTilesProcessorClass.isAssignableFrom(configProcessorClass)) {
      String msg = "Specified RequestProcessor not compatible with saif.";
      throw new ServletException(msg);
    }
  } catch (Exception ex) {
    throw new ServletException(ex);
  } 
  .........
  .........
}

它似乎与Tiles插件相同,因此我指出的文章包含答案。

I haven't worked with the Struts Action Invocation Framework before but the exception message is familiar to me from Tiles. Tiles throws a message like this: Specified RequestProcessor not compatible with TilesRequestProcessor so I think that besides the familiarity of the message (in your case Specified RequestProcessor not compatible with saif) there is also a chance that the cause be the same.

Here is an article that fixes this on the Tiles plugin. Might help you.

When the Struts Servlet is initialized it does an init of all the plugins. The message should come from the init method of your plugin and if it is the same as Tiles then a test with Class.isAssignableFrom should be the cause.

EDIT: Looked up the source code for the SAIF plugin and found this in it:

protected void initRequestProcessorClass(ActionServlet servlet, ModuleConfig config) throws ServletException {
  .........
  .........
  ControllerConfig ctrlConfig = config.getControllerConfig();
  String configProcessorClassname = ctrlConfig.getProcessorClass();
  .........
  .........
  // Check if specified request processor is compatible with saif.
  try {
    Class saifProcessorClass = SAIFRequestProcessor.class;
    Class saifTilesProcessorClass = SAIFTilesRequestProcessor.class;
    Class configProcessorClass = Class.forName(configProcessorClassname);
    if (!saifProcessorClass.isAssignableFrom(configProcessorClass)
       && !saifTilesProcessorClass.isAssignableFrom(configProcessorClass)) {
      String msg = "Specified RequestProcessor not compatible with saif.";
      throw new ServletException(msg);
    }
  } catch (Exception ex) {
    throw new ServletException(ex);
  } 
  .........
  .........
}

It seems to be the same as with Tiles plugin so the article that I indicated contains the answer.

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