<tfoot id='dqPI4'></tfoot>

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

  • <legend id='dqPI4'><style id='dqPI4'><dir id='dqPI4'><q id='dqPI4'></q></dir></style></legend>

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

        Jsp Struts2中Action类的调用函数

        Calling function of Action class in Jsp Struts2(Jsp Struts2中Action类的调用函数)
        1. <legend id='eLcuM'><style id='eLcuM'><dir id='eLcuM'><q id='eLcuM'></q></dir></style></legend>

            <tbody id='eLcuM'></tbody>

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

              <bdo id='eLcuM'></bdo><ul id='eLcuM'></ul>
                • <i id='eLcuM'><tr id='eLcuM'><dt id='eLcuM'><q id='eLcuM'><span id='eLcuM'><b id='eLcuM'><form id='eLcuM'><ins id='eLcuM'></ins><ul id='eLcuM'></ul><sub id='eLcuM'></sub></form><legend id='eLcuM'></legend><bdo id='eLcuM'><pre id='eLcuM'><center id='eLcuM'></center></pre></bdo></b><th id='eLcuM'></th></span></q></dt></tr></i><div id='eLcuM'><tfoot id='eLcuM'></tfoot><dl id='eLcuM'><fieldset id='eLcuM'></fieldset></dl></div>
                  <tfoot id='eLcuM'></tfoot>
                  本文介绍了Jsp Struts2中Action类的调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个小场景.我有两个 POJO 类和两个表 UserDomain(表的名称相同).每个用户将属于一个且仅一个域.

                  I have a little scenario. I have two POJO classes and two tables User and Domain(same name for tables). Every user will belong to one and only one domain.

                  我有两个 Action 类,一个是 UsersManagemntAction,另一个是 DomainsManagementAaction.我使用 UsersManagemntAction 来执行与用户相关的 CRUD 操作.在我的 User 类中,我有一个属性 domainId.该属性将包含用户所属的 Domainid.我的问题是,当我在 jsp 页面中显示用户信息时,我会显示 domainId 和用户信息.这是因为用户对象将具有 domainId.而不是显示 domainId 我想显示域名.我无法执行连接查询.我应该解决这个问题,当我显示用户信息时,我在用户管理操作类中调用一个函数,将 domainId 传递给该函数.该函数对 Domain 表执行搜索并返回域名.该解决方案不起作用,因为我没有找到将 domainId 传递给该函数的任何方法.我可以调用 UsersManagemntAction 类的函数,但无法传递 domainId.请帮助我或以其他方式向我建议替代解决方案.

                  I have two Action classes one is UsersManagemntAction and other is DomainsManagementAaction. I use UsersManagemntAction to perform CRUD operations that are related to users. In my User class I have an attribute domainId. This attribute will contain the id of Domain to which user belong. My problem is that I when I show user information in jsp page I show the domainId with the users information. This is because user object will have the domainId. Rather than showing domainId I want to show domain name. I can't perform join query. what i supposed to solve this problem that when I am displaying information of user I call a function in user management action class pass the domainId to that function. That function perform search on Domain table and return the domain name. This solutions is not working because I didn't find any way to pass domainId to that function. I am able to call a function of UsersManagemntAction class but unable to pass domainId. Please help me or otherwise suggest me an alternative solution.

                  下面是JSP页面和User类的代码.

                  Below is the code of JSP page and User class.

                  JSP:

                  <s:if test="users.size() > 0">
                  <tbody>
                      <s:iterator value="users" >
                          <tr>
                              <td><s:property   value="userId" /></td>
                              <td><s:property   value="loginId" /></td>
                              <td><s:property   value="password" /></td>
                  
                  <td><s:property value="email" /></td>
                  <td><s:property value="domainName" /></td> <!--- It will call getDomainName function in   action class -->
                  </td>
                  </tr>
                  </s:iterator>
                  </tbody>
                  

                  User.java:

                  public class User {
                  private Long userId;
                  private String loginId;
                  private String password;
                  private String email;
                  private Long domainId;
                  
                  public String getPassword() {
                      return password;
                  }
                  
                  public void setPassword(String password) {
                      this.password = password;
                  }
                  
                  public Long getDomainId() {
                      return domainId;
                  }
                  
                  public void setDomainId(Long domainId) {
                      this.domainId = domainId;
                  }
                  
                  
                  
                  public void setUserId(Long userId) {
                      this.userId = userId;
                  }
                  
                  public Long getUserId() {
                      return userId;
                  }
                  
                  @Override
                  public String toString() {
                      return "User [domainId=" + domainId + ", password=" + password + ", userId=" + userId + ", Login Id=" + getLoginId() + "]";
                  }
                  
                  public String getLoginId() {
                      return loginId;
                  }
                  
                  public void setLoginId(String loginId) {
                      this.loginId = loginId;
                  }
                  
                  public String getEmail() {
                      return email;
                  }
                  
                  public void setEmail(String email) {
                      this.email = email;
                  }
                  
                  }
                  

                  推荐答案

                  你可以从值栈中获取它,同时你在值栈的顶部迭代 User 对象,所以你可以到那里去

                  You can get it from the value stack, while you are iterating the User object in on top of the value stack, so you can get it there

                  public String getDomainName(){
                    User user = (User) ActionContext.getContext().getValueStack().peek();
                    return domainService.findDomainById(user.getDomainId()).getName();
                  }
                  

                  这篇关于Jsp Struts2中Action类的调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的游戏框架.有什么建议吗?)
                    • <bdo id='F13tZ'></bdo><ul id='F13tZ'></ul>
                      <tfoot id='F13tZ'></tfoot>
                        <tbody id='F13tZ'></tbody>

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

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