JSP表单实例

<form action="" method="post">
					<table border="1" cellspacing="" cellpadding="">
						<tr><td align="center" colspan="2">用户注册页面</td></tr>
						<tr><td>用户名:</td><td><input type="text" size="29"></td></tr>
						<tr><td>密码:</td><td><input type="password" size="30"></td></tr>
						<tr><td align="center" colspan="2"><input type="button" value="确定" size="10"></td></tr>
						<tr><td>性别:</td><td><input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女</td></tr>
						<tr><td>爱好:</td><td><input type="checkbox" name="wan" value="wanyouxi">玩游戏 
						<input type="checkbox" name="chidxi" value="chidix">吃东西 
						<input type="checkbox" name="shuijiao value="sj">睡觉
						</td></tr>
						<tr><td>家庭住址:</td><td><select name="address">
						<option value="山西">山西</option>
						<option value="黑龙江">黑龙江</option>
						<option value="四川">北京</option>
						</select>
						<select name="市">
						<option value="朔州市">朔州市</option>
						<option value="哈尔滨">哈尔滨</option>
						<option value="成都市">成都</option>
						</select>
						<select name="区">
						<option value="朔城区">朔城区</option>
						<option value="江北">江北</option>
						<option value="家乡">家乡</option>
						</select>
						</td></tr>
						<tr><td colspan="2">上传文件:<input type="file"></td></tr>
						<tr><td align="center">其他:</td><td><textarea rows="10" cols="30">
						</textarea></td></tr>
						<tr><td colspan="2" align="center"><input type="submit" value="提交"></td></tr>
						
					</table>
					</form>
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserInfo people = new UserInfo();
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=gb2312");
		people.setUsername(request.getParameter("username"));
		people.setPassword(request.getParameter("password"));
		people.setSex(request.getParameter("sex"));
		String habbString[] = request.getParameterValues("hobby");
		String aihaoString="";
		if(habbString!=null)
		for(int i=0;i<habbString.length;i++)
			aihaoString += habbString[i]+",";
		
		people.setHobby(aihaoString);
		people.setAddress(request.getParameter("address")+request.getParameter("shi")+request.getParameter("shi"));
		
		people.setMeno(request.getParameter("meno"));
		InforService caozuo = new InforService();
		System.out.println("建立InforService对象");
		caozuo.insert(people);
	}

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值