Jsp表单测试-checkbox获取,radio获取
来源:互联网 发布:linux下ant的安装 编辑:程序博客网 时间:2024/06/01 15:27
u 源程序:
form.jsp中的代码:
<%@ page language="java"import="java.util.*"pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML 4.01 Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>My JSP'form.jsp' starting page</title>
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<metahttp-equiv="description"content="This is my page">
<!--
<link rel="stylesheet"type="text/css"href="styles.css">
-->
</head>
<body>
<formaction="./form_resp.jsp"method="post">
username:<inputtype="text"name="username"><br>
password: <input type="password"name="password"><br>
兴趣:学习<inputtype="checkbox"name="interest"value="学习">
旅游<inputtype="checkbox"name="interest"value="旅游">
睡觉<inputtype="checkbox"name="interest"value="睡觉"><br>
性别:男<inputtype="radio"name="gender"value="男">
女<inputtype="radio"name="gender"value="女"><br>
学历:<selectname="xueli">
<optionvalue=""></option>
<optionvalue="小学">小学</option>
<option value="初中">初中</option>
<option value="高中">高中</option>
<optionvalue="大学">大学</option>
</select>
<br>
说明:<textareaname="text"></textarea><br>
图片:<imgsrc="images/google.jpg"height=80pxwidth=200px><br>
文件上传:<inputtype="file"><br>
<inputtype="submit"value="submit"> <inputtype="reset"value="reset"> <inputtype="button"value="button"onclick="javascript:alert('hello world');">
</form>
</body>
</html>
form_resp.jsp中的代码:
<%@pageimport="java.awt.Checkbox"%>
<%@ page language="java"import="java.util.*"pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML 4.01 Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>My JSP'form_resp.jsp' starting page</title>
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<metahttp-equiv="description"content="This is my page">
<!--
<link rel="stylesheet"type="text/css"href="styles.css">
-->
</head>
<body>
<% String username = request.getParameter("username");
String password = request.getParameter("password");
String[] values =request.getParameterValues("interest");
String gender = request.getParameter("gender");
String xueli = request.getParameter("xueli");
String text = request.getParameter("text");
out.println("username:"+username+"<br>");
out.println("password:"+password+"<br>");
out.println("兴趣: ");
for(String value :values){
Stringval = new String(value.getBytes("iso-8859-1"),"utf-8");
out.println(val);
}
String gen = newString(gender.getBytes("iso-8859-1"),"utf-8");
out.println("<br>"+"性别: "+gen+"<br>");
String xue = newString(xueli.getBytes("iso-8859-1"),"utf-8");
out.println("学历: "+xue+"<br>");
out.println("说明: "+text+"<br>");
%>
</body>
</html>
u 运行结果:
form.jsp页面:
form_resp.jsp表单响应页面:
- Jsp表单测试-checkbox获取,radio获取
- 获取radio或者checkbox
- JQUERY获取form表单text,areatext,radio,checkbox,select值
- JQUERY获取form表单text,areatext,radio,checkbox,select值
- JQUERY获取form表单text,areatext,radio,checkbox,select值
- jQuery获取,遍历和操作表单元素Select,checkbox,radio
- jQuery获取,遍历和操作表单元素Select,checkbox,radio
- Jquery 设置,获取radio checkbox
- js中获取jsp表单中radio类型的值
- Jquery 获取表单text,areatext,radio,checkbox,select值的代码
- 解决form表单序列化获取不到未选中的checkbox,radio的值
- javascript获取radio或者checkbox的值
- JQUERY获取radio,checkbox,select值
- JQUERY获取radio,checkbox,select值
- 如何获取radio checkbox的选中value
- Jquery获取radio,checkbox,select的值
- Jquery获取radio,checkbox,select的值
- Jquery获取设置radio select checkbox 文本框
- android横竖屏切换时候Activity的生命周期
- gedit配置
- prepare for the provincial time --10.1--Hard to Play
- 解决ORACLE锁表问题
- 三角形1
- Jsp表单测试-checkbox获取,radio获取
- c++如何查询变量的类型
- iOS speex 配置
- Tomcat学习之二:tomcat安装、配置及目录文件说明
- 生理周期(中国剩余定理)
- IT思想题
- 使用cxf发布webservice(JavaApplication)
- C++中namespace的使用
- C# textbox中光标定位到最后一行