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

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

      如何更改 Struts 操作类中的语言环境?

      How to change locale in a Struts action class?(如何更改 Struts 操作类中的语言环境?)
          <i id='WRatz'><tr id='WRatz'><dt id='WRatz'><q id='WRatz'><span id='WRatz'><b id='WRatz'><form id='WRatz'><ins id='WRatz'></ins><ul id='WRatz'></ul><sub id='WRatz'></sub></form><legend id='WRatz'></legend><bdo id='WRatz'><pre id='WRatz'><center id='WRatz'></center></pre></bdo></b><th id='WRatz'></th></span></q></dt></tr></i><div id='WRatz'><tfoot id='WRatz'></tfoot><dl id='WRatz'><fieldset id='WRatz'></fieldset></dl></div>
          <tfoot id='WRatz'></tfoot>
            <legend id='WRatz'><style id='WRatz'><dir id='WRatz'><q id='WRatz'></q></dir></style></legend>
            1. <small id='WRatz'></small><noframes id='WRatz'>

                <bdo id='WRatz'></bdo><ul id='WRatz'></ul>

                  <tbody id='WRatz'></tbody>
              • 本文介绍了如何更改 Struts 操作类中的语言环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个 Action 类,我想获取我的应用的语言环境并在此处更改它,但我不知道如何也找不到答案.

                I have an Action class, and I want to get the locale of my app and change it here, but I don't know how and can't find an answer.

                我可以使用 super.getLocale().toString();

                但是如何设置语言环境我不知道.

                public class LoginAction extends ActionSupport {
                
                    private String login;
                    private String password;
                    private String language;
                
                    @Override
                    public String execute() throws Exception {
                        String result = Factory.INSTANCE.getUserDao().checkUser(login, password);
                        if(result == null){
                            return ERROR;
                        }
                        return SUCCESS;
                    }
                
                    public String getLogin() {
                        return login;
                    }
                
                    public void setLogin(String login) {
                        this.login = login;
                    }
                
                    public String getPassword() {
                        return password;
                    }
                
                    public void setPassword(String password) {
                        this.password = password;
                    }
                
                    public String getLanguage() {
                        return language;
                    }
                
                    public void setLanguage(String language) {
                        this.language = language;
                    }
                
                    @Override
                    public void validate() {
                        super.validate();
                        if(login.isEmpty() | password.isEmpty()){
                            addActionError(getText("login.error"));
                        }else {
                            addActionMessage(getText("login.correct"));
                        }
                    }
                }
                


                我想在上面的 Action 类中更改我的应用程序的语言环境.我该怎么做?


                I want to change the locale for my app right in the above Action class. How can I do this?

                推荐答案

                使用 ActionContext.getContext().setLocale(locale) 并将其放入 HTTP sessionsession.put(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, locale).

                Use ActionContext.getContext().setLocale(locale) and to put it in HTTP session session.put(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, locale).

                这篇关于如何更改 Struts 操作类中的语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)

                <tfoot id='6JQd2'></tfoot>

              • <legend id='6JQd2'><style id='6JQd2'><dir id='6JQd2'><q id='6JQd2'></q></dir></style></legend>
                  <bdo id='6JQd2'></bdo><ul id='6JQd2'></ul>

                    <small id='6JQd2'></small><noframes id='6JQd2'>

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

                      <tbody id='6JQd2'></tbody>