<bdo id='HfDXr'></bdo><ul id='HfDXr'></ul>
  • <small id='HfDXr'></small><noframes id='HfDXr'>

    <i id='HfDXr'><tr id='HfDXr'><dt id='HfDXr'><q id='HfDXr'><span id='HfDXr'><b id='HfDXr'><form id='HfDXr'><ins id='HfDXr'></ins><ul id='HfDXr'></ul><sub id='HfDXr'></sub></form><legend id='HfDXr'></legend><bdo id='HfDXr'><pre id='HfDXr'><center id='HfDXr'></center></pre></bdo></b><th id='HfDXr'></th></span></q></dt></tr></i><div id='HfDXr'><tfoot id='HfDXr'></tfoot><dl id='HfDXr'><fieldset id='HfDXr'></fieldset></dl></div>

    <legend id='HfDXr'><style id='HfDXr'><dir id='HfDXr'><q id='HfDXr'></q></dir></style></legend>
    <tfoot id='HfDXr'></tfoot>

        Struts 2 Convention Plugin 定义多个父包

        时间:2023-09-28
          • <bdo id='7H7na'></bdo><ul id='7H7na'></ul>
          • <i id='7H7na'><tr id='7H7na'><dt id='7H7na'><q id='7H7na'><span id='7H7na'><b id='7H7na'><form id='7H7na'><ins id='7H7na'></ins><ul id='7H7na'></ul><sub id='7H7na'></sub></form><legend id='7H7na'></legend><bdo id='7H7na'><pre id='7H7na'><center id='7H7na'></center></pre></bdo></b><th id='7H7na'></th></span></q></dt></tr></i><div id='7H7na'><tfoot id='7H7na'></tfoot><dl id='7H7na'><fieldset id='7H7na'></fieldset></dl></div>
              1. <legend id='7H7na'><style id='7H7na'><dir id='7H7na'><q id='7H7na'></q></dir></style></legend>
                  <tbody id='7H7na'></tbody>

                <tfoot id='7H7na'></tfoot>
              2. <small id='7H7na'></small><noframes id='7H7na'>

                  本文介绍了Struts 2 Convention Plugin 定义多个父包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发 Struts 2 Web 应用程序,使用 Convention Plugin 通过注释来配置所有内容.我的一些动作类遇到了障碍,我想在其中使用多个父包.我确实在 Apache 的网站 上找到了一种方法 - 但是这似乎已被弃用.它不起作用,抛出 Type mismatch: cannot convert from String[] to String 错误.

                  I'm working on Struts 2 web application, using the Convention Plugin to configure everything via annotations. I'm hitting a snag with some of my action classes, where I'd like to use multiple parent packages. I did find a means of doing it on Apache's site - but that appears to be deprecated. It does not work, throwing back a Type mismatch: cannot convert from String[] to String error.

                  @ParentPackage({"my-parent-package1, my-parent-package2"})
                  package com.mycompany.myapp.actions
                  
                  import org.apache.struts2.config.ParentPackage;
                  

                  我正在使用 Struts 2.2.1.是否可以通过注释授予多个父包的操作?他们会将此作为一项功能删除,这似乎很奇怪.

                  I am using Struts 2.2.1. Is it possible to grant an action multiple parent packages via annotations? Seems odd that they would have removed this as a feature.

                  推荐答案

                  你不能用注解来做到这一点,但它仍然可以通过 XML 配置来实现.javadoc 说

                  You cannot do it with annotations, but it's still possible via XML config. The javadoc says

                  这个注解允许actions修改他们的父包正在使用.由于 XWork 包是由 Convention 插件创建的通过动作存在的 Java 包,有一些棘手的问题处理 XWork 父包和 XWork 包的命名空间用于发现的动作,以便同一个包中的两个动作可以指定不同的父级和命名空间而不会发生冲突.

                  This annotation allows actions to modify the parent package that they are using. Since XWork packages are created by the Convention plugin via the Java packages that the actions exist in, there is some tricky handling of XWork parent packages and namespaces of the XWork packages for discovered actions so that two actions in the same package can specify different parents and namespaces without collision.

                  为了正确处理这个问题,XWork 包的名称使用以下格式构建操作:

                  In order to handle this correctly, the name of the XWork package that actions are placed into is built using this format:

                  <java-package>##

                  <java-package>#<parent-xwork-package>#<namespace>

                  这意味着java包中可能有多个父包.但是您不能在同一个类或包上放置两个或多个 @ParentPackage 注释.正如您注意到的那样,父包不能有数组.但是您至少可以有两个父包,一个在包定义中,另一个在动作类中.不幸的是,配置构建器为此注解构建了两个配置,但操作配置仅针对具有注解的配置创建.

                  This means that is possible to have multiple parent packages in the java package. But you cannot place two or more @ParentPackage annotations on the same class or package. And as you notices cannot have array for parent packages. But you can at least have two parent packages one at the package definition and other at the action class. And unfortunate the config builder builds two configs for this annotations but the action config is only created for the one that has an annotation.

                  这篇关于Struts 2 Convention Plugin 定义多个父包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:java注释中的私有字段 下一篇:外行术语中的 Spring 传播示例

                  相关文章

                  最新文章

                    <small id='ocQ8q'></small><noframes id='ocQ8q'>

                    <legend id='ocQ8q'><style id='ocQ8q'><dir id='ocQ8q'><q id='ocQ8q'></q></dir></style></legend>

                    <tfoot id='ocQ8q'></tfoot>

                        <bdo id='ocQ8q'></bdo><ul id='ocQ8q'></ul>
                    1. <i id='ocQ8q'><tr id='ocQ8q'><dt id='ocQ8q'><q id='ocQ8q'><span id='ocQ8q'><b id='ocQ8q'><form id='ocQ8q'><ins id='ocQ8q'></ins><ul id='ocQ8q'></ul><sub id='ocQ8q'></sub></form><legend id='ocQ8q'></legend><bdo id='ocQ8q'><pre id='ocQ8q'><center id='ocQ8q'></center></pre></bdo></b><th id='ocQ8q'></th></span></q></dt></tr></i><div id='ocQ8q'><tfoot id='ocQ8q'></tfoot><dl id='ocQ8q'><fieldset id='ocQ8q'></fieldset></dl></div>