<tfoot id='pi6E5'></tfoot>

    1. <legend id='pi6E5'><style id='pi6E5'><dir id='pi6E5'><q id='pi6E5'></q></dir></style></legend>

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

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

      1. 从 Struts 2.3.33 迁移到 Struts 2.5.12 LocalizedTextUtil 被移除

        时间:2023-10-14
          <tbody id='lxcnc'></tbody>

        <tfoot id='lxcnc'></tfoot>
        • <bdo id='lxcnc'></bdo><ul id='lxcnc'></ul>
        • <legend id='lxcnc'><style id='lxcnc'><dir id='lxcnc'><q id='lxcnc'></q></dir></style></legend>

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

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

                  本文介绍了从 Struts 2.3.33 迁移到 Struts 2.5.12 LocalizedTextUtil 被移除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我们尝试从 Struts 2.33 迁移到 Struts 2.5.12.

                  We tried to migrate from Struts 2.33 to Struts 2.5.12.

                  我们在应用程序中直接使用了LocalizedTextUtil.

                  We used LocalizedTextUtil in our application directly.

                  我发现 LocalizedTextUtil 已从 com.opensymphony.xwork2.util.LocalizedTextUtil 中删除.我试图搜索但找不到任何东西

                  I found that the LocalizedTextUtil is removed from com.opensymphony.xwork2.util.LocalizedTextUtil. I tried to search but could not find any thing

                  我发现了一些类,如 StrutsLocalizedTextProviderGlobalLocalizedTextProvider 但似乎它们不是我可以使用的.

                  I found some classes like StrutsLocalizedTextProviderand GlobalLocalizedTextProvider but it seems they are not what I can use them.

                  我已查看 migration-guide,但找不到任何关于它.

                  I have reviewed migration-guide but could not find any comment about it.

                  有什么选择?

                  推荐答案

                  struts.xml应该设置为:

                  The struts.xml should be set as:

                  <constant name="struts.xworkTextProvider" value="DefaultTextProvider" />
                  <bean type="com.opensymphony.xwork2.TextProvider" name="DefaultTextProvider" class="utils.CustomTextProvider" scope="default" />
                  

                  并且 CustomStrutsTextProviderFactory 可以添加捆绑包

                  And CustomStrutsTextProviderFactory could add bundles

                  public class MyTextProviderFactory implements TextProviderFactory {
                  
                  protected LocaleProviderFactory localeProviderFactory;
                  protected LocalizedTextProvider localizedTextProvider;
                  
                  @Inject
                  public MyTextProviderFactory(LocaleProviderFactory localeProviderFactory, LocalizedTextProvider localizedTextProvider) {
                      this.localeProviderFactory = localeProviderFactory;
                      this.localizedTextProvider = localizedTextProvider;
                  
                      this.localizedTextProvider.addDefaultResourceBundle("messages/label");
                      this.localizedTextProvider.addDefaultResourceBundle("messages/customerA/label");
                  
                  }
                  
                  @Override
                  public TextProvider createInstance(Class clazz) {
                      TextProvider instance = getTextProvider(clazz);
                      if (instance instanceof ResourceBundleTextProvider) {
                          ((ResourceBundleTextProvider) instance).setClazz(clazz);
                          ((ResourceBundleTextProvider) instance).setLocaleProvider(localeProviderFactory.createLocaleProvider());
                      }
                      return instance;
                  }
                  
                  @Override
                  public TextProvider createInstance(ResourceBundle bundle) {
                      TextProvider instance = getTextProvider(bundle);
                      if (instance instanceof ResourceBundleTextProvider) {
                          ((ResourceBundleTextProvider) instance).setBundle(bundle);
                          ((ResourceBundleTextProvider) instance).setLocaleProvider(localeProviderFactory.createLocaleProvider());
                      }
                      return instance;
                  }
                  
                  protected TextProvider getTextProvider(Class clazz) {
                      return new TextProviderSupport(clazz, localeProviderFactory.createLocaleProvider(), localizedTextProvider);
                  }
                  
                  protected TextProvider getTextProvider(ResourceBundle bundle) {
                      return new TextProviderSupport(bundle, localeProviderFactory.createLocaleProvider(), localizedTextProvider);
                  }
                  

                  }

                  完整归功于@LukazLenart https://issues.apache.org/jira/浏览/WW-4829

                  Complete credits to @LukazLenart https://issues.apache.org/jira/browse/WW-4829

                  这篇关于从 Struts 2.3.33 迁移到 Struts 2.5.12 LocalizedTextUtil 被移除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Struts 2 在拦截器中重置动作实例 下一篇:如何在 Struts 2 中使用 jQuery Ajax 检查唯一用户?

                  相关文章

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

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

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