创建JavaBean
public class user {
private String name;
private String address;
private int age;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getAddress()
{
return address;
}
public void setAddress(String address)
{
this.address = address;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
}
创建表单
<form action="neirong.jsp" method="get">
姓名:<input type="text" id="name" name="name"><br>
地址:<input type="text" id="address" name="address"><br>
年龄:<input type="text" id="age" name="age"><br>
<input type="submit" value="提交">
输出
<jsp:useBean id="user" class="com.user" scope="session"></jsp:useBean>
<jsp:setProperty name="user" property="*"></jsp:setProperty>
<jsp:getProperty name="user" property="name"/>
<jsp:getProperty name="user" property="address"/>
<jsp:getProperty name="user" property="age"/>