前台jsp页面中的表单提交后,在数据库中查看到值为null

张广淮 发布于 2016/11/24 14:22
阅读 679
收藏 0
<div id="service">     <!-- 调用main.css中的service属性,与下面的class样式结合 -->
	<a href="#" class="yuyue trigger-default" target="_blank">在线预约</a>    <!-- href="#"链接到本页    target="_blank"浏览器打开一个新窗口 -->
</div>
<!-- 添加form表单 -->
<table id="border" cellSpacing=1 cellPadding=0 width="100%" align=center border=0>
<form name="infoForm" id="infoForm" method="post" action="webadmin/servlet/BookingServlet" target="actionifram">  <!-- BookingServlet在指定的框架中打开 -->
<input type="hidden" id="method" name="method" value="save">
<input type="hidden" id="id" name="id" value="${a.id}">
<div id="modal-default" class="iziModal">
<!-- 弹窗内容设置 -->
<!-- 提交按钮:输入框以及确认框 -->
   <ul class="datefrm">     
    <li><input type="text" class="form-control input1" value="联系人" name="linkman" id="linkman" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = '联系人';}"></li>
    <li><input type="text" class="form-control input1" value="联系电话" name="linktel" id="linktel" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = '联系电话';}"></li>
    <li class="center"><input name="" type="button" class="btn-primary btn1" value="提交" onclick="javascript:toSubmit();"></li>     <!-- onclick="javascript:toSubmit();" -->
     <!--  <li class="tip center">已有<font color="red">36</font>位业主预约</li> -->         <!-- 将预约人数去除 --> <!-- value="${a.id}即为所有的预约人数" -->
   </ul>
</div>
</form>



<!--预约弹窗-->
<link href="css/iziModal.css" rel="stylesheet">
<script src="js/iziModal.js" type="text/javascript"></script>
<script type="text/javascript">
 /* iziModal:窗口插件 */ 
	$("#modal-default").iziModal({
		title: "预约服务",
		subtitle: "",
		iconClass: 'icon-announcement',
		width: 400,
		padding: 20
	});
	
	  $(document).on('click', '.trigger-default', function (event) {
		event.preventDefault();
		$('#modal-default').iziModal('open');
	});  
</script>
<iframe name="actionifram" id="actionifram" border="0" frameborder="no" marginwidth="0" marginheight="0" height="0" width="0" style="display:none"></iframe>
<form method="post" action="" name="actionform" target="actionifram" style="display:none"></form>



<script language="JavaScript">
/* 点击提交按钮之后,将编辑窗口关闭 */
function ColseWin(){
	window.parent.ColseWin();
}
/* 预约服务---提交按钮onclick事件 */
function toSubmit(){
	var linkman=document.getElementById("linkman").value;    //联系人
	var linktel=document.getElementById("linktel").value;    //联系电话
	if (linkman =="联系人") {
		alert("请输入联系人!");
		return false;
	}
	if (linktel=="联系电话") {
		alert("请输入联系电话!");
		return false;
	}
	window.infoForm.submit();   /* 提交到infoForm  form表单 */  /* 创建form表单。http协议 */
	alert("linkman=="+linkman);
}
</script>



以下是问题补充:

@张广淮:在前台页面点击预约按钮,在弹出的编辑框中填写数据,点击提交按钮,数据插入了,但是在后台数据库中查看到的数据为null, (2016/11/24 14:24)
加载中
0
张广淮
张广淮

servlet中的代码

public void save(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			Booking booking = (Booking) RequestUtil.copyParam(Booking.class,
					request);

			bookingDao.add(booking);
			request.setAttribute("success", "预约服务增加成功!");
		}
		request.getRequestDispatcher("/webadmin/pages/success1.jsp").forward(request, response);
		System.out.println("response=="+response);
	}



返回顶部
顶部