使用带注释的 Struts 2 消息存储拦截器

发布于 2024-08-15 19:23:55 字数 775 浏览 0 评论 0原文

我目前正在将 Struts 2 应用程序转换为使用约定插件和注释而不是 XML 配置。

原始 XML 如下所示:

    <action name="store" method="store"
        class="com.company.webapp.dop.AuthorAction">
        <result name="success" type="redirectAction">list</result>
        <result name="input" type="tiles">.author.edit
        </result>
        <interceptor-ref name="store">
            <param name="operationMode">STORE</param>
        </interceptor-ref>
        <interceptor-ref name="defaultStack" />
    </action>

我已将其替换为,

@Action(value="store", interceptorRefs=@InterceptorRef("store"))
public String store() throws Exception
{
    ....
}

但我不确定如何将参数传递给消息存储拦截器。有什么想法吗?

I am currently converting a Struts 2 application to use the Convention plugin and Annotations instead of the XML configuration.

The original XML looks like:

    <action name="store" method="store"
        class="com.company.webapp.dop.AuthorAction">
        <result name="success" type="redirectAction">list</result>
        <result name="input" type="tiles">.author.edit
        </result>
        <interceptor-ref name="store">
            <param name="operationMode">STORE</param>
        </interceptor-ref>
        <interceptor-ref name="defaultStack" />
    </action>

which I have replaced with

@Action(value="store", interceptorRefs=@InterceptorRef("store"))
public String store() throws Exception
{
    ....
}

but I am unsure how to pass in the parameter to the Message Store Interceptor. Any thoughts?

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

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

发布评论

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

评论(1

妳是的陽光 2024-08-22 19:23:55

阅读 http://www.jarvana.com/jarvana/view/org/apache/struts/struts2-convention-plugin/2.1.8/struts2-convention- plugin-2.1.8-javadoc.jar!/index.html
,答案是执行以下操作:

@Action(value = "store", interceptorRefs = {@InterceptorRef(value = "store", params = {"operationMode", "STORE"})})

After reading the Javadoc's at http://www.jarvana.com/jarvana/view/org/apache/struts/struts2-convention-plugin/2.1.8/struts2-convention-plugin-2.1.8-javadoc.jar!/index.html
,the answer was to do the following:

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