日期:2014-05-18  浏览次数:20803 次

jsp怎么通过form表单把bean对象提交给servlet??
*.jsp:
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=utf-8 ">
<title> 修改信息 </title>
<style   type= "text/css ">
<!--

<!--
.kuan   {     font-size:   9pt;   color:   #ff0000;   border:   1px   solid;   background-color:#CCFF99;   border-color:   #CCFF99   #CCFF99   #3399FF}
-->
.tb{   border:   1px   solid;   border-color:   #000000}
.tr{           border:   1px   solid;   border-color:   #000000}
.style2   {color:   #000000}
.style3   {color:   #000000}
.style4   {font-size:   12px;   font-family:   "宋体 ";}
body   {
background-color:   #ffffff;
}
-->
</style>
</head>
<body>
<%
                //从servlet   读取的AddressBook     bean   d对象
AddressBook   addr   =   (AddressBook)   request
      .getAttribute( "addressBook ");
String   name   =   addr.getname();
System.out.println( "name= "   +   name);
String   sex   =   addr.getsex();
%>
<table   width= "648 "   height= "158 "   border= "0 "   align= "center "
cellspacing= "0 ">
<tr>
<td   valign= "top ">
<form   name= "form1 "   method= "get "   action= "JspServlet ">
<input   name= "id "   type= "hidden "   value= "-1 ">
<table   width= "468 "   height= "293 "   border= "1 "   cellspacing= "0 "   class= "tb ">
<tr>
<td   height= "23 "   colspan= "3 ">
<img   src= "../images/bar1.gif "   width= "508 "   height= "25 ">
</tr>
<tr   bgcolor= "#CCFF99 ">
<td   width= "181 ">
<span   class= "style4 "> 姓名: </span>
<input   name= "name "   type= "text "   class= "kuan "   size= "15 "  
            value= " <%=name%> ">
</td>
<td   width= "277 ">
<span   class= "style2 "> 性别 </span> <span   class= "style3 "> : </span>
<input   name= "sex "   type= "radio "   value= "男 "
          <%   if   (sex.equals( "男 "))   {%>   checked   <%}%> > 男
<input   type= "radio "   name= "sex "   value= "女 "
          <%if   (sex.equals( "女 ")){%>   checked   <%}%> > 女
</td>
</tr>
<p   align= "center ">
<input   type= "submit "   name= "Submit "   value= "保   存 ">
<input   type= &