我有类Person
:
package Model;
import java.util.Set;
public class Person {
private String firstName ;
private String lastName ;
private int id ;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setId(int id) {
this.id = id;
}
}
我创建了带有以下详细信息的jsp表单Person
:
<fieldset>
<legend>Create new customer</legend>
<form action="CreatePersonServlet" method="GET">
ID : <input type="text" name="id" /> <br />
First Name : <input type="text" name="firstName" /> <br />
Last Name : <input type="text" name="lastName " /><br />
</form>
</fieldset>
我有CreatePersonServlet
servlet 的方法:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Person newPerson= new Person () ;
}
我应该写什么,以便根据从 jsp 表单发送的newPerson
对象将填充他的所有成员。request
在jsp中我是这样知道的
<jsp:useBean id="newPerson" class="Person" scope="session"/>
<jsp:setProperty name="newPerson" property="*"/>
但现在该成员的详细信息不在,session
而是在request