Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在JSP中访问实体属性_Java_Jsp_Spring Mvc - Fatal编程技术网

Java 在JSP中访问实体属性

Java 在JSP中访问实体属性,java,jsp,spring-mvc,Java,Jsp,Spring Mvc,我有两个对象雇员和雇员地址 这是我的两件物品- 雇员 现在,我如何将其作为对象传递给JSP以收集员工信息 如何显示地址属性 例如:-我显示的名字如下,工作正常,但如何显示address.street、address.zip等 <form:form method="post" action="addemployee" commandName="employee"> <table class="TFtable"> <tr>

我有两个对象雇员和雇员地址

这是我的两件物品-

雇员

现在,我如何将其作为对象传递给JSP以收集员工信息

如何显示地址属性

例如:-我显示的名字如下,工作正常,但如何显示address.street、address.zip等

<form:form method="post" action="addemployee" commandName="employee">
        <table class="TFtable">
        <tr>
            <td><form:label path="firstname"><spring:message code="label.firstname"/></form:label></td>
            <td><form:input path="firstname" /></td>
        </tr>

首先,您的员工可能有多个地址。那么你到底想拆开哪个地址呢?在任何情况下,您都可以将实体的实例直接传递给模型,并使用它。有什么问题吗?我只有2个地址..想知道如何指第一次出现和第二次出现..例如:-dob我直接指ie;path=dob..如何引用路径中的地址….街道地址[0]?。。。
@Entity
@Table(name="employee_address")
@NamedQuery(name="EmployeeAddress.findAll", query="SELECT e FROM EmployeeAddress e")
public class EmployeeAddress implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;

    private String apt_no;

    private String city;

    private String country;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="create_dt")
    private Date createDt;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="end_dt")
    private Date endDt;

    private String state;

    private String street_addr;

    private String zip_Code;

    //bi-directional many-to-one association to Employee
    @ManyToOne
    @JoinColumn(name="emp_id")
    private Employee employee;

    public EmployeeAddress() {
    }

    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getApt_no() {
        return this.apt_no;
    }

    public void setApt_no(String apt_no) {
        this.apt_no = apt_no;
    }

    public String getCity() {
        return this.city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return this.country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public Date getCreateDt() {
        return this.createDt;
    }

    public void setCreateDt(Date createDt) {
        this.createDt = createDt;
    }


    public Date getEndDt() {
        return this.endDt;
    }

    public void setEndDt(Date endDt) {
        this.endDt = endDt;
    }

    public String getState() {
        return this.state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getStreet_addr() {
        return this.street_addr;
    }

    public void setStreet_addr(String street_addr) {
        this.street_addr = street_addr;
    }

    public String getZip_Code() {
        return this.zip_Code;
    }

    public void setZip_Code(String zip_Code) {
        this.zip_Code = zip_Code;
    }

    public Employee getEmployee() {
        return this.employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }
<form:form method="post" action="addemployee" commandName="employee">
        <table class="TFtable">
        <tr>
            <td><form:label path="firstname"><spring:message code="label.firstname"/></form:label></td>
            <td><form:input path="firstname" /></td>
        </tr>