后台action
/** * 仪器设备计划信息查询 * * @param param * @return */ public String queryInstrumentPlan() { String name = request.getParameter("name"); String x_sbxh = request.getParameter("x_sbxh"); String serial_no = request.getParameter("serial_no"); String vendor = request.getParameter("vendor"); String flag = request.getParameter("flag"); String begin_date = request.getParameter("beginDate");// 开始日期 String end_date = request.getParameter("endDate");// 线束日期 Map<String, Object> param = new HashMap<String, Object>(); param.put("name", name); param.put("flag", flag); param.put("begin_date", begin_date); param.put("end_date", end_date); param.put("x_sbxh", x_sbxh); param.put("serial_no", serial_no); param.put("vendor", vendor); List<Instruments> list = sampleService.queryInstrumentPlan(param); request.setAttribute("list", list); if (null == flag) { Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); begin_date = year + "-" + "01-01"; end_date = year + "-" + "12-31"; request.setAttribute("begin_date", begin_date); request.setAttribute("end_date", end_date); return "instrumentPlan"; } else { return "instrumentPlan_" + flag; } }
前台页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <%@ taglib prefix="lw" uri="/labway"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.01 Transitional//EN"> <html> <head> <title>设备仪器信息查询</title> <link href="css/content.css" rel="stylesheet" type="text/css" /> <link href="css/jquery.datepick.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript" src="js/jquery.datepick.js"></script> <script type="text/javascript" src="js/jquery.datepick-zh-CN.js"></script> </head> <body> <div id="biaoti" class="tbtitle01"> <b>设备仪器计划信息查询</b> </div> <div class="space_h_5"></div> <div> <s:form action="FunctionsAction_queryInstrumentPlan" name="pageForm"> <table width="98%" border="0" cellpadding="3" cellspacing="0" class="tb_form1"> <tr> <th >设备编号/名称</th> <td > <s:textfield name="name" id="name" onkeyup="toUpperCase(this)" size="8"/> </td> <th >型号</th> <td > <s:textfield name="x_sbxh" id="x_sbxh" /> </td> <th >出厂号</th> <td > <s:textfield name="serial_no" id="serial_no" /> </td> <th >生产单位</th> <td > <s:textfield name="vendor" id="vendor" /> </td> </tr> <tr> <th width="80px">开始日期:</th> <td width="80px"> <s:textfield name="beginDate" id="beginDate" size="7" value="%{#request.begin_date}"/> </td> <th width="80px">结束日期:</th> <td width="80px"> <s:textfield name="endDate" id="endDate" size="7" value="%{#request.end_date}"/> </td> <th width="80px">计划类别</th> <td> <s:select name="flag" id="flag" list="#{‘calib‘:‘计量设备检定计划‘,‘pm‘:‘维护保养计划‘,‘func‘:‘功能核查计划‘,‘time‘:‘期间核查计划‘}"/> </td> <td><input type="button" value="查询" onclick="doQuery()"> <input type="button" value="导出" onclick="doExport()"></td> </tr> </table> <div class="space_h_5"></div> <div id="main"></div> </s:form> </div> <script type="text/javascript"> $(document).ready(function(){ //日期控件 $("#beginDate").datepick({dateformat:‘yy-mm-dd‘}); $("#endDate").datepick({dateformat:‘yy-mm-dd‘}); }); function doQuery(){ var name = $("#name").attr("value"); var flag = $("#flag").attr("value"); var beginDate = $("#beginDate").attr("value"); var endDate = $("#endDate").attr("value"); if(beginDate=="" || endDate==""){ alert("请填写日期!");return false; } $.ajax({ url:‘FunctionsAction_queryInstrumentPlan‘, data:{flag:flag,name:name,beginDate:beginDate,endDate:endDate}, type:‘post‘, success:function(data){ $("#main").html(data); }, error:function(data){ alert("查询数据出错"); } }); } function doExport() { var beginDate = $("#beginDate").attr("value"); var endDate = $("#endDate").attr("value"); if(beginDate=="" && endDate==""){ alert("请填写日期!");return false; } pageForm.action="FunctionsAction_exportInstrumentPlan"; pageForm.submit(); pageForm.action="FunctionsAction_queryInstrumentPlan"; } function doDel(id){ if(confirm("确认删除当前选中计划")){ var name = $("#name").attr("value"); var flag = $("#flag").attr("value"); var beginDate = $("#beginDate").attr("value"); var endDate = $("#endDate").attr("value"); if(beginDate=="" || endDate==""){ } $.ajax({ url:‘FunctionsAction_deleteInstrumentPlan‘, data:{flag:flag,name:name,beginDate:beginDate,endDate:endDate,id:id}, type:‘post‘, success:function(data){ $("#main").html(data); }, error:function(data){ alert("查询数据出错"); } }); } } </script> </body> </html>
注:<s:textfield name="beginDate" id="beginDate" size="7" value="%{#request.begin_date}"/>
用%{#request.begin_date}这种方式接收数据
时间: 2024-09-30 20:40:22