| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 662 人关注过本帖
标题:jsp新手求一获取表单值的问题
只看楼主 加入收藏
尸体一只
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-11-22
结帖率:0
收藏
已结贴  问题点数:20 回复次数:5 
jsp新手求一获取表单值的问题
<!--普通用户注册-->
                   <div class="form  "  id="tabC_1" >
                        <form id="reg_form" method="post" action="dealwith.jsp">
                            <fieldset>
                            <!--邮箱-->
                                <div class="frm frmGender" id="field_mail">
                                    <p class="frmT"><em>邮箱:</em></p>
                                    <div class="frmC" ><input tabindex="1"  type="text" name="mail" autocomplete="off" disableautocomplete="" id="field_mail_input" class="validate-email validate-required"><p class="frmTip"><b id="mail_tip">填写常用邮箱,这将是登录帐号。</b></p></div>
                                </div>
                             <!--密码-->
                                <div class="frm frmPw" id="field_password">
                                    <p class="frmT"><em>密码:</em></p>
                                    <div class="frmC" ><input tabindex="2" type="password" name="password" class="validate-password validate-required validate-l6l16"><p class="frmTip"><b id="password_tip" class="tipb"></b></p></div>
                                </div>
                            <!--昵称-->
                                <div class="frm" id="field_nickname">
                                    <p class="frmT"><em>昵称:</em></p>
                                    <div class="frmC" ><input tabindex="3"  type="text" name="nickname" class="validate-nec validate-required validate-l2l12"><p class="frmTip"><b id="nickname_tip" class="tipb"></b></p></div>
                                </div>
                           <!--性别-->
                                <div class="frm frmGender" id="field_sex">
                                    <p class="frmT"><em>性别:</em></p>
                                    <div class="frmC" ><label class="rado"><input tabindex="4"  checked="checked" type="radio" name="sex" value="0">女</label><label class="rado"><input  tabindex="5" type="radio" value="1" name="sex">男</label></div>
                                </div>
                            <!--年龄-->
                                <div class="frm" id="field_nickname">
                                    <p class="frmT"><em>年龄:</em></p>
                                    <div class="frmC" ><input tabindex="5"  type="text" name="age" class="validate-nec validate-required validate-l2l12"><p class="frmTip"><b id="age_tip" class="tipb"></b></p></div>
                                </div>
                            <!--地区-->     
                                <div class="frm" id="field_local">
                                    <p class="frmT"><em>地区:</em></p>
                                    <div class="frmC">
                                        <form>
                                            <select name="city">
                                            <option value="北京市" selected="selected">北京市</option><option value="上海市">上海市</option><option value="山东">山东</option><option value="安徽">安徽</option><option value="重庆">重庆</option><option value="江苏">江苏</option><option value="浙江">浙江</option><option value="江西">江西</option><option value="福建">福建</option><option value="吉林">吉林</option><option value="辽宁">辽宁</option><option value="内蒙古">内蒙古</option><option value="新疆">新疆</option><option value="广东">广东</option><option value="广西">广西</option><option value="湖南">湖南</option><option value="湖北">湖北</option><option value="河南">河南</option><option value="河北">河北</option><option value="山西">山西</option><option value="陕西">陕西</option><option value="西藏">西藏</option><option value="云南">云南</option><option value="青海">青海</option><option value="甘肃">甘肃</option><option value="四川">四川</option><option value="贵州">贵州</option><option value="宁夏">宁夏</option><option value="黑龙江">黑龙江</option><option value="海南">海南</option><option value="天津">天津</option><option value="香港">香港</option><option value="澳门">澳门</option><option value="台湾">台湾</option><option value="海外">海外</option>
                                        </select>
                                        </form>
                                                                                
                                    </div>
                                </div>
                            <!--验证码-->      
                                    <div class="frm frm_vc" id="field_captchaCode">
                                        <p class="frmT"><em>验证码:</em></p>
                                        <div class="frmC"><input type="text" class="validate-required" name="captchaCode" tabindex="8" >
                                            <p class="vcflush" id="flushValidCode" ><img id="validCode" title="点击刷新图片"><a href="" class="fuc">刷新</a></p>
                                            <p class="frmTip"><i class="i"></i><b id="captchaCode_tip" class="tipb"></b></p>
                                        </div>
                                    </div>
                             <!--submit-->
                             <div class="frm frmSubmit">
                                 <div class="frmC">
                                     <p class="btns"><a href="dealwith.jsp" class="btn btnB2 jsBtnReg"><b>立即注册</b></a></p>
                                 </div>
                             </div>
                             <!--协议-->                              
                                <div class="frm frmSubmit" >
                                    <div class="frmC">
                                        <label class="cbox">同意<a target="_blank" href=null data-ca="shiyongxieyi_click">TeaMe网络服务使用协议</a></label>
                                    </div>
                                </div>
                            </fieldset>
                            <input type="hidden" name="captchaSeed" id="captchaSeed"/>
                        </form>
                    </div>
这是“dealwith.jsp”里面的代码
<!--普通用户注册-->
                   <div class="form"  id="tabC_1" >     
                 
                            <fieldset>
                            <!--邮箱-->
                                <div class="frm frmGender" id="field_mail">
                                    <p class="frmT"><em>邮箱:</em></p>
                                    <div class="frmC" ><%=request.getParameter("mail") %>
                                    </div>
                                </div>
                             <!--密码-->
                                <div class="frm frmPw" id="field_password">
                                    <p class="frmT"><em>密码:</em></p>
                                    <div class="frmC" ><%=request.getParameter("password") %>
                                    </div>
                                </div>
                            <!--昵称-->
                                <div class="frm" id="field_nickname">
                                    <p class="frmT"><em>昵称:</em></p>
                                    <div class="frmC" ><%=request.getParameter("nickname") %>
                                </div>
                                </div>
                           <!--性别-->
                                <div class="frm frmGender" id="field_sex">
                                    <p class="frmT"><em>性别:</em></p>
                                    <div class="frmC" ><%=request.getParameter("sex") %>
                               </div>
                                </div>
                            <!--年龄-->
                                <div class="frm" id="field_nickname">
                                    <p class="frmT"><em>年龄:</em></p>
                                    <div class="frmC" ><%=request.getParameter("age") %>
                                </div>
                                </div>
                            <!--地区-->     
                                <div class="frm" id="field_local">
                                    <p class="frmT"><em>地区:</em></p>
                                    <div class="frmC">
                                        <%=request.getParameter("city") %>
                                                                                
                                    </div>
                                </div>
                              
                            </fieldset>
                                            
                    </div>
       这里request.getParameter不能获取到填写在表单里的信息是为什么?
搜索更多相关主题的帖子: action method 用户 
2012-11-22 14:56
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
收藏
得分:20 
表单是提交上去才获取的嘛,而且request.getParameter 是获取INGPUT 里的NAME名称的值
2012-11-22 15:49
尸体一只
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-11-22
收藏
得分:0 
回复 2楼 hhwz
后面有提交的部分,用的是input里面的name啊,提交以后,页面上显示的都是null
2012-11-24 23:32
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
收藏
得分:0 
回复 3楼 尸体一只
  <p class="btns"><a href="dealwith.jsp" class="btn btnB2 jsBtnReg"><b>立即注册</b></a></p>
你注意看看这一句,href="dealwith.jsp" 这个地址直接连接到了这个JSP里 并没有提交
2012-11-27 09:19
尸体一只
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-11-22
收藏
得分:0 
回复 4楼 hhwz
因为刚开始学嘛,看书上写的是在form里面用action提交的,我就在form里面写了action="dealwith.jsp",还是要用别的方式提交啊?求指导啊~~我一定吧分都给你
2012-11-28 16:50
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
收藏
得分:0 
在form里写提交地址没有错。但是提交的方法错了,因为你没有用submit的按钮的话 就要用JS来提交

<a href="javascript:document.getElementById('reg_form').submit();" class="btn btnB2 jsBtnReg">
把这句改成这样 就能提交了 原来的是跳转到dealwith.jsp 而不是提交到dealwith.jsp
2012-11-30 10:50
快速回复:jsp新手求一获取表单值的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038974 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved