<html>
<head>
<title>数据输入</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<p>请输入数据</p>
<form method="post" action="SayHelloBean.jsp" >
<p>姓名
<input type="text" name="name">
性别
<select name="sex">
<option value="先生">先生</option>
<option value="女士">女士</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="提交">
</p>
</form>
<p> </p>
<p> </p>
</div>
</body>
</html>
<%@ page language="java" import="bean.HelloBean;" %>
<%@ page contentType="text/html;charset=gb2312" %>
<%
//request.getParameter("name");
//request.setCharacterEncoding("gb2312");
%>
<jsp:useBean id="hello" class="bean.HelloBean" scope="request" >
<jsp:setProperty name="hello" property="*" />
</jsp:useBean>
<html>
<head>
<title>HelloBean</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<p> </p>
<p align="center">
<font size="4">欢迎
<font color="#0000FF"><b>
<%--
<%=new String(hello.getName().getBytes("ISO8859_1"),"GBK")%>
--%>
</b></font>
<%--
<%=new String(hello.getSex().getBytes("ISO8859_1"),"GBK")%>
--%>
</font></p>
<jsp:getProperty name="hello" property="name"/>
<jsp:getProperty name="hello" property="sex"/>
</body>
</html>
package bean;
public class HelloBean{
private String name="";
private String sex="";
public HelloBean(){
}
public void setName( String name ){
this.name = name;
}
public String getName(){
return this.name;
}
public void setSex( String sex ){
this.sex = sex;
}
public String getSex(){
return this.sex;
}
}