首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

关于传值的有关问题

2012-02-19 
关于传值的问题 我在框架页A页面里进行查询,将查询的结果在B页面里显示.可是查询的结果还在A页面里显示,为

关于传值的问题

我在框架页A页面里进行查询,将查询的结果在B页面里显示.可是查询的结果还在A页面里显示,为什么不在B页里显示呢??我用include也不行啊!!谁能帮帮忙啊?
A代码

<%@   page   language= "java "   import= "java.util.* "   pageEncoding= "GB2312 "%>
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> </title>
</head>

<body>
<br/>
<h3> <div   align= "center "   >   查询用户 </h3>
<table   width= "176 "   height= "88 "   border= "1 ">
<form   name= "form1 "   method= "post "   action= "query.jsp ">
    <tr>
        <td   width= "76 "> 查询方式: </td>
        <td   >
            <select   name= "select "   size= "1 ">
                <option   value= "1 "> ID号 </option>
                <option   value= "2 "> 姓名 </option>
<option   value= "3 "> 性别 </option>
<option   value= "2 "> 年龄 </option>
<option   value= "2 "> 邮箱 </option>

            </select>         </td>
    </tr>
    <tr>
        <td> 查询内容: </td>
        <td   width= "76 "> <input   type= "text "   name= "txtwhere "   size= "10 "> </td>
    </tr>
    <tr>
        <td   align= "center "> <input   type= "submit "   name= "subt "   value= "提交 ">   </td>
        <td   align= "center "   > <input   type= "reset "   name= "reset "   value= "重写 "> </td>
    </tr>
    </form>
</table>
</body>
</html>


B页代码

<%@page   language= "java "   import= "java.util.* "   pageEncoding= "GB2312 "%>
<jsp:directive.page   import= "com.zjw.db.Db "   />
<jsp:directive.page   import= "java.sql.ResultSet "   />

<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> </title>
</head>

<body>

<table   border= "1 ">
   


<%   Db   db   =   new   Db();
String   sel   =   request.getParameter( "select ");
String   txtwhere   =   request.getParameter( "txtwhere ");
ResultSet   rs=null;
if(sel==null   &&   txtwhere==null){
rs=db.userInfo();
}else{
rs   =   db.userQuery(sel,   txtwhere);
}
String   sex   =   " ";
while   (rs.next())   {


String   s   =   rs.getString(4);
Integer   ints   =   new   Integer(s);
if   (ints   ==   1)   {
sex   =   "男 ";
}   else   {
sex   =   "女 ";
}
out.println( " <tr   > ");
out.println( " <td   width= '50 '   align= 'center '> ID </td> ");
out.println( " <td   width= '50 '   align= 'center '> 名字 </td> ");
out.println( " <td   width= '50 '   align= 'center '> 性别 </td> ");
out.println( " <td   width= '80 '   align= 'center '> 年龄 </td> ");
//out.println( " <td> 邮箱 </td> ");
out.println( " <td   width= '120 '   align= 'center '> 住址 </td> ");
//out.println( " </tr> ");
out.println( " <tr> ");
out.println( " <td   align= 'center '>   "   +   rs.getString( "uid ")   +   " </td> ");
out.println( " <td   align= 'center '> "   +   rs.getString( "uname ")   +   " </td> ");
out.println( " <td   align= 'center '> "   +   sex   +   " </td> ");
out.println( " <td   align= 'center '> "   +   rs.getString( "uage ")   +   " </td> ");
//out.println( " <td> "+rs.getString( "uemail ")+ " </td> ");
out.println( " <td   align= 'center '> "   +   rs.getString( "uaddress ")   +   " </td> ");
out.println( " </tr> ");
}
rs.close();
db.close();
%>
</table>

</body>
</html>



[解决办法]
将A的JSP
<form name= "form1 " method= "post " action= "query.jsp ">

改为试一试


<form name= "form1 " method= "post " action= "query.jsp " target= "_blank ">

热点排行