English 中文(简体)
• 如何回收入侵中的一批物体?
原标题:How to iterate over a collection of objects in struts2?

我无法将储存在一个用户物体中,2 停泊。

我的行动、形式和使用者是:

public class Project {
    private String name;
    private int id;

    // getter and setter for name & id
}

public class User {
    private String name;
    private List<Project> projects;
    :
    :
    public List<Project> getProjects() {
      // fetch projects from database and add to projects

      return projects;
    }
}

pulbic class login extends ActionSupport {
    private User user;
    public String execute() {
       user = new User();
       return SUCCESS;
    }

    public User getUser () {
      return user;
    }
}

现在,在jsp网页上,我需要展示用户的所有项目。

JSP 法典:

   <s:iterator value="user.projects" var="proj" status="key">           
        <td> <s:property value="${proj.name}" /> </td>  
        <td> <s:property value="${proj.id}" /> </td>  
    </s:iterator>

但是,这名主持人没有工作。 我如何能够这样做?

问题回答

当主持人把该项目推向上层时,可能不需要老金。

<s:iterator value="user.projects">           
    <td> <s:property value="name" /> </td> 
    <td> <s:property value="id" /> </td>  
</s:iterator>

请注意,如果你想用{}打上标语,则应在标注OGNL的序号上打字,其中1美元为“EL”。 如果不以违约的方式加以评价,那么你只需要把言词划在复词2的标子中,因为在某些情形下,通常需要评估,而不是在你们赢得的其他人中,常常需要做,因为主子评价/而不是像大多数人期望的那样。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签