开发者

Problem accesing email property with help of Expression Language/JSTL

开发者 https://www.devze.com 2023-03-02 16:07 出处:网络
In my Servlet: person.setEmail(eMail); request.getSession().setAttribute(\"person\", person); RequestDispatcher rd = req开发者_开发百科uest.getRequestDispatcher(\"/JSPAddress\");

In my Servlet:

person.setEmail(eMail);
request.getSession().setAttribute("person", person);

RequestDispatcher rd = req开发者_开发百科uest.getRequestDispatcher("/JSPAddress");
rd.forward(request, response);

My Bean Class:

private String eMail;

public Person(String eMail) {
    setEmail(eMail);
}

public String getEmail() {
    return eMail;
}
public void setEmail(String Email) {
    this.eMail = Email;
}

In my JSPAddress:

<input type="text" size="45" name="email" value='<c:out value="${person.eMail}" />' >

What I want:

  • An email value in textfield, which is set in a Servlet


EL accesses properties by getters, not directly by the field. If your setter is named setEmail() then your getter is likely named getEmail(), so the property name is really email, not eMail.

Thus, this should do

${person.email}
0

精彩评论

暂无评论...
验证码 换一张
取 消