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

为什么request.getParameter("XX")会为空??
一个页面advsearch_submit.jsp中有
<td   width= "114 "   height= "50 "> <strong> 书名: </strong> </td>
<form     method= "post "   action= "advsearch.jsp ">
        <td   width= "465 "> <input   name= "bookname "   type= "text "     size= "30 "   maxlength= "20 "   /> </td>

</form>
..
<form     method= "post "   action= "index_searchresult3.jsp ">
        <td> <input   name= "search "   type= "submit "   value= "开始搜索 "   /> </td>
    </tr>
    </form>

点击开始搜索-〉advsearch.jsp中输出
String     name=request.getParameter( "bookname ");
为null??
其中index_searchresult3.jsp   include   advsearch.jsp




------解决方案--------------------
bookname并未把值传递给advsearch.jsp,开始搜索按钮所提交的作用范围只是在你定义的第二个表单里面,而第一个表单里虽然输入了信息,但是并未有提交按钮进行提交,所以虽然你index_searchresult3.jsp 载入了advsearch.jsp,但是request.getParameter( "bookname ");仍为空~~
------解决方案--------------------
<form method= "post " action= "index_searchresult3.jsp ">
<td> <input name= "search " type= "submit " value= "开始搜索 " /> </td>
</tr>
</form>
这个表单提交的时候根本就没有将bookname这个变量提交过去,bookname在上边的一个表单中
改成下边的形式估计就可以了:
<form method= "post " action= "index_searchresult3.jsp ">
<td width= "465 "> <input name= "bookname " type= "text " size= "30 " maxlength= "20 " /> </td>
<td> <input name= "search " type= "submit " value= "开始搜索 " /> </td>
</tr>
</form>

------解决方案--------------------
<form method= "post " action= "advsearch.jsp ">
<td width= "465 "> <input name= "bookname " type= "text " size= "30 " maxlength= "20 " /> </td>

<td> <input name= "search " type= "submit " value= "开始搜索 " /> </td>
</tr>
</form>

这样写几没问题了吧
------解决方案--------------------
应该可以用document.all.form.action= "xxx.jsp ";来控制,然后用document.all.form.submit();提交。