怎么使用Java提取html表单元素
1个回答
2016-05-26 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
实现代码:
<form action="input.do" name="formkk">
<table>
<tbody>
<tr>
<td>text:</td>
<td>
<input type="text" name="text">
</td>
</tr>
<tr>
<td>password:</td>
<td>
<input type="password" name="pass">
</td>
</tr>
<tr>
<td>radio:</td>
<td>
<input type="radio" name="xingbie" value="1">
男
<input type="radio" name="xingbie" value="2">
女
</td>
</tr>
<tr>
<td>checkbox:</td>
<td>
足球:<input type="checkbox" name="hobby" value="1" />
篮球:<input type="checkbox" name="hobby" value="2" />
拍球:<input type="checkbox" name="hobby" value="3" />
斗球:<input type="checkbox" name="hobby" value="4" />
</td>
</tr>
<tr>
<td>hidden:</td>
<td>
<input type="hidden" value="123" name="hidden"/>
</td>
</tr>
<tr>
<td>option:</td>
<td>
<select name="opt" id="opt">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</td>
</tbody>
</table>
<input type="button" value="提交" onclick="javascript:check()"/>
</form>String[] hobbys = request.getParameterValues("hobby"); //checkbox
String text = request.getParameter("text"); //text
String password = request.getParameter("password"); //password
String xingbie = request.getParameter("xingbie"); //radio
request.getParameter("hidden");
request.getParameter("opt"); //select
<form action="input.do" name="formkk">
<table>
<tbody>
<tr>
<td>text:</td>
<td>
<input type="text" name="text">
</td>
</tr>
<tr>
<td>password:</td>
<td>
<input type="password" name="pass">
</td>
</tr>
<tr>
<td>radio:</td>
<td>
<input type="radio" name="xingbie" value="1">
男
<input type="radio" name="xingbie" value="2">
女
</td>
</tr>
<tr>
<td>checkbox:</td>
<td>
足球:<input type="checkbox" name="hobby" value="1" />
篮球:<input type="checkbox" name="hobby" value="2" />
拍球:<input type="checkbox" name="hobby" value="3" />
斗球:<input type="checkbox" name="hobby" value="4" />
</td>
</tr>
<tr>
<td>hidden:</td>
<td>
<input type="hidden" value="123" name="hidden"/>
</td>
</tr>
<tr>
<td>option:</td>
<td>
<select name="opt" id="opt">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</td>
</tbody>
</table>
<input type="button" value="提交" onclick="javascript:check()"/>
</form>String[] hobbys = request.getParameterValues("hobby"); //checkbox
String text = request.getParameter("text"); //text
String password = request.getParameter("password"); //password
String xingbie = request.getParameter("xingbie"); //radio
request.getParameter("hidden");
request.getParameter("opt"); //select
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询