SpringMVC事例

大家好:

         今天做的一个时间显示的功能,费了不少力气,跟大家分享一下!

        实例就不写了,写下实现吧!

/*
	 * 显示挂号时间的方法
	 */
	<span style="font-size:14px;">@RequestMapping(value = "/wx/registrationTime", method = RequestMethod.GET)
	public String registrationTime(HttpServletRequest request) throws Exception {
		Format format=new SimpleDateFormat("yyyy-MM-dd EEE");
		List<String> list = new ArrayList<String>();
		  long time=0;
		  for (int day=0; day<7; day++ ) {
		  Date today=new Date();
		  time=(today.getTime()/1000)+60*60*24*day;
		  Date newDate=new Date();
		  newDate.setTime(time*1000); 
		  String DayList = format.format(newDate);
		  list.add(DayList);
		  }
		<strong><span style="color:#FF0000;">request.setAttribute("list",list);</span></strong>
		return WX_HOSP_NO;
	}</span>

<span style="font-size:14px;"><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/view/common/tags.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>请选择挂号时间</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
		<%@ include file="/view/common/resource.jsp"%>
		<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/resources/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/resources/ztree/js/jquery.ztree.core-3.5.js"></script>  
		<script type="text/javascript" src="<%=request.getContextPath()%>/resources/ztree/js/jquery.ztree.excheck-3.5.js"></script> 
		<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/ztree/css/zTreeStyle/zTreeStyle_3.5.css" type="text/css"/> 
	
	</head>
<body>
	<table>
		<strong><span style="color:#FF6600;"><c:forEach items="${list}" var="list">
		<tr>
			<td>
			<input type="text" id="dayTime" name="dayTime" value="${list}" onclick="Registration(this.value)"/>
			</td>
		</tr>
		</c:forEach></span></strong>
	</table>
	<script type="text/javascript">
	function Registration(dayTime){//点击时间后跳挂号科室 
		var dayTime = dayTime.substr(0,10);
		var pid = 0;
		var hospId = 1;
	<span style="color:#FF6600;"> var url ="/benmu/wx/pageJump?pid="+pid+"&hospId="+hospId+"&dayTime="+dayTime; 
	 location.href =url; //get请求</span>
		
	}
	</script>
</body>
</html>
</span>
<span style="font-size:14px;">/**
	 *查询科室预览 一级菜单 (页面跳转)
	 */
	@RequestMapping(value = "/wx/pageJump", method = RequestMethod.GET)
	public String pageJump(
			HttpServletRequest request,
			@RequestParam(value = "pid", required = true) String pid,
			@RequestParam(value = "hospId", required = true) String hospId,
			<span style="color:#FF9900;">@RequestParam(value = "dayTime", required = true) String dayTime</span>
			) throws Exception {
		WxHospDept wxHospDept = new WxHospDept();
		wxHospDept.setPid(pid);
		wxHospDept.setHospId(hospId);
		List<WxHospDept> entity =wxHospDeptService.getWxHospDeptParentList(wxHospDept);
		<span style="color:#FF0000;">request.setAttribute("entity",entity);
		request.setAttribute("dayTime",dayTime);</span>
		return WX_HOSP_DEPT;
	}</span>

<span style="font-size:14px;"><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/view/common/tags.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>选择科室列表</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
		<%@ include file="/view/common/resource.jsp"%>
		<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/resources/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/resources/ztree/js/jquery.ztree.core-3.5.js"></script>  
		<script type="text/javascript" src="<%=request.getContextPath()%>/resources/ztree/js/jquery.ztree.excheck-3.5.js"></script> 
		<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/ztree/css/zTreeStyle/zTreeStyle_3.5.css" type="text/css"/> 
	
	</head>
	<body>
	<div>
	<input type="hidden" id="pName" name="PName" value=""/>
	<span style="color:#FF0000;"><input type="hidden" id="dayTime" name="dayTime" value="${dayTime}"/></span>
	</div>
	<!-- 一级目录 -->
		<table>
	
			<c:forEach items="${entity}" var="entity">
			<tr>
				<td>
				<input type="hidden" id="fdid" name="fdid" value="${entity.fdid}"/>
				<input type="hidden" id="pid" name="pid" value="${entity.pid}"/>
				<input type="hidden" id="hospId" name="hospId" value="${entity.hospId}"/>
				<input type="text" id="name" name="name" value="${entity.name}" onclick="show(${entity.fdid},${entity.hospId},this.value)"/>
				</td>
			</tr>
			</c:forEach>
		</table>
<!--二级目录 方法实现 -->
<script type="text/javascript">
	function show(fdid,hospId,name){
		var name =name;
		var pid = fdid;	 //obj 当前科室的fdID作二级目录的Pid 
		var hospId = hospId;
		$("#pName").val(name);
		$.post("/benmu/wx/wxHospDeptController",
	       {
			"pid" : pid,
			"hospId" : hospId
			},
	     function(data){
			//拼接Html
 			if(data.entity!=null){
			//var splitHtml = "<table> ";
			var	pName = $("#pName").val();
					var splitHtml = "";
 				for(var i = 0; i<data.entity.length;i++ ){
 				splitHtml += pName+"--"+data.entity[i].name;
 				splitHtml +="         ";
 				/* splitHtml+="<input type='hidden' id='fdid' name='fdid' value="+data.entity[i].fdid+"/>";
 				splitHtml+="<input type='hidden' id='pid' name='pid' value="+data.entity[i].pid+"/>";
 				splitHtml+="<input type='hidden' id='hospId' name='hospId' value="+data.entity[i].hospId+"/>";
 				splitHtml+="<input type='text' id='name' name='name' value="+data.entity[i].name+"/>";
 				splitHtml+="</td></tr>"; */
 				}
 			//splitHtml+="</table>";
 				alert(splitHtml);
 			}
	    });
	}
</script>
</body>
</html></span>
注意:页面间的传值问题!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值