radio取值,<s:radio name="view[%{#status.index}]" list='#{"同意":"同意","不同意":"不同意"}' theme="simple" />

本文介绍了一段使用JSP实现的审批流程代码,包括视图管理、数据操作及返回成功提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jsp:
<s:radio name="view[%{#status.index}]" list='#{"同意":"同意","不同意":"不同意"}' theme="simple"  /> 
action: 
private List<Apply> list;
 private JdbcApplyDao dao = new JdbcApplyDao();
 private List<String> view = new ArrayList<String>();

 public String execute() throws Exception {
  list = (List<Apply>) session.get("list");
  for (int i = 0; i < view.size(); i++) {
   dao.updateView(view.get(i), list.get(i).getId());
  }
  httpRequest.setAttribute("tipmsg", "审批完成");
  return "success";
 }  

<%@page import="com.haitaiinc.inpordnurse.ylz.dto.common.Bm_ygxx00DTO"%> <%@page import="com.haitaiinc.common.CommUtil"%> <%@ page import="com.haitaiinc.servlet.JSP,com.haitaiinc.util.Dict,com.haitaiinc.htdb.sd_haitai2.dto.*"%> <%@page import="com.haitaiinc.htdb.sd_haitai2.dto.Inpatient"%> <%@page import="com.haitaiinc.common.CommonAction"%> <%@page import="com.haitaiinc.htcpoe.InpordSystemConfig"%> <%@page import="com.haitaiinc.util.Dict"%> <%@page import="com.haitaiinc.Util"%> <%@page import="java.text.SimpleDateFormat"%> <%@page import="java.util.Calendar"%> <%@page import="java.util.Date"%> <%@page import="java.util.List"%> <%@page import="java.util.ArrayList"%> <%@page import="com.haitaiinc.servlet.JSP"%> <%@page import="com.haitaiinc.common.Const"%> <%@page import="com.haitaiinc.util.Dict"%> <%@page import="com.haitaiinc.inpordnurse.ylz.dto.yrqd.Bm_bqks00DTO"%> <jsp:useBean id="token" class="java.lang.String" scope="request"></jsp:useBean> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=7" ></meta> <%=JSP.getHtCSSDef(request)%> <%=JSP.getPageCSSDef(request) %> <%=JSP.getHtJSDef(request)%> <script src="ht-5.0/ht-core.js" type="text/javascript"></script> <script src="<%=request.getContextPath() %>/js/jquery-1.8.3.js"></script> <script src="<%=request.getContextPath() %>/js/jquery-ui-1.11.4/jquery-ui.js"></script> <link href="<%=request.getContextPath() %>/js/jquery-ui-1.11.4/jquery-ui.css" rel="stylesheet" type="text/css" /> <script src="<%=request.getContextPath() %>/js/showLoading.js"></script> <script src="<%=request.getContextPath() %>/js/orderdrug/common-edit-drug.js"></script> <script src="/nurse-business-extend/extendforylz/commjs/nurse-synthetical-oprate.js"></script> <% String titleName = "病区收入统计"; String currentTime = Util.getCurrentDate("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar=Calendar.getInstance(); String currentday = simpleDateFormat.format(calendar.getTime()); calendar.add(Calendar.MONTH,-1); String lastmonth = simpleDateFormat.format(calendar.getTime()); //医嘱检索结果区下方增加空白区域显示医嘱的特殊说明 String showDesc = "false"; showDesc = "true"; List<Bm_bqks00DTO> bqksList = (ArrayList)request.getAttribute("bqksList"); List<Bm_ygxx00DTO> yhryList = (ArrayList)request.getAttribute("yshsList"); String[] monthsList = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"}; %> <title><%=titleName%></title> <script type="text/javascript" src="js/json2.js"></script> <script type="text/javascript"> </script> <style> html{height:100%;overflow:hidden;} .div-radio { margin: 0px 0px 0px 0px; } .div-inline1{ margin-top: 5px; margin-left: -6px; padding-left: 10px; height: 25px; } </style> </head> <body style="height:100%"> <div id="qrDiv" style="height:100%;"> <form name="searchForm" id="searchForm" method="post"> <table cellpadding="1" cellspacing="1" style="table-layout: fixed;width: 100%; height:100%;"> <colgroup> <col id="colId" width="100%"> </colgroup> <tr> <td class="main_bg_search" style="width: 100%;" colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <div class="div-inline">  科室: <select id="bqks" name="bqks" style="width: 120px;height: 23px;" onchange="changeYhry(this);"> <option selected="selected" value="">全部</option> <% for(int j=0; bqksList!=null&&j<bqksList.size();j++){ Bm_bqks00DTO sd = bqksList.get(j); %> <option value="<%=Util.toString(sd.getKsh000()) %>"><%=Util.toString(sd.getBmmc00()) %></option> <%} %> </select> </div>  <div class="div-inline"> <span> <label><input type="radio" style="margin-left: -10px;" name="itemStatus" value="xmlb" checked="checked" onclick="checkYhry(this);searchList();"/>按项目类别</label> <label><input type="radio" name="itemStatus" value="jtxm" onclick="checkYhry(this);searchList();" />按具体项目</label> <label><input type="radio" name="itemStatus" value="yhry" onclick="checkYhry(this);searchList();" /> 按医护人员: <select id="yhry" name="yhry" disabled="disabled" style="width: 120px;height: 23px;"> <option selected="selected" value="">全部</option> <% for(int j=0; yhryList!=null&&j<yhryList.size();j++){ Bm_ygxx00DTO sd = yhryList.get(j); %> <option value="<%=Util.toString(sd.getYgbh00()) %>"><%=Util.toString(sd.getZwxm00()) %></option> <%} %> </select> </label> </span> </div>  </td> </tr> <tr> <td>    <div class="div-inline div-checkbox-or-radio div-inline1"> <span> <label><input type="radio" checked="checked" style="margin-left: -10px;" name="timeTypes" value="0" onclick="checkTime(this);"/> 月份: <select id="months" name="months" style="width: 120px;height: 22px;margin-top: 1px;"> <option selected="selected" value="0">当前月份</option> <% for(int j=0; monthsList!=null&&j<monthsList.length;j++){ %> <option value="<%=j+1 %>"><%=monthsList[j] %></option> <%} %> </select> </label> </span> </div>   <div class="div-inline div-checkbox-or-radio div-inline1" style="margin-bottom: 3px;"> <span> <label><input type="radio" style="margin-left: -10px;" name="timeTypes" value="1" onclick="checkTime(this);"/> 时间: <input type="text" readonly name="startTime" id="startTime" style="width: 100px;" disabled="disabled" onclick="fPopUpCalendarDlg(startTime);searchList();" value="<%=Util.format(lastmonth, "yyyy-MM-dd")%>" /> - <input type="text" readonly name="endTime" id="endTime" style="width: 100px;" disabled="disabled" onclick="fPopUpCalendarDlg(endTime);searchList();" value="<%=Util.format(currentday, "yyyy-MM-dd")%>" /> </label> </span> </div> <div class="div-inline" style="margin-bottom: 5px;"> <input type="button" class="order_button" value="查  询" id=&#39;queryBtn&#39; onclick="searchList();"/>   <input type="button" class="order_button" value="导出Excel" id=&#39;exportExcelBtn&#39; onclick="exportExcel();"/>   </div> </td> </tr> </table> </td> </tr> <tr id="listTr"> <td id="dataTd" height="84.5%" width="100%" align="left" valign="top"> <table cellpadding="1" cellspacing="1" style="table-layout: fixed;width: 100%; height:100%;"> <tr> <td height="100%" width="100%" ><!-- 医嘱信息展示列表区 --> <div id="listshow" style="overflow:hidden;height:100%;width:100%;" ></div> </td> </tr> </table> </td> </tr> </table> </form> </div> <div id="swElement" style="display: none;"> </div> </body> <script type="text/javascript"> var token = "<%=token%>"; var menu = "<%=titleName%>"; searchList(); //展示统计列表 function searchList(){ showLoading(); var url = "do?module=inpordnurse&action=YlzBqsrtj&method=searchIncomeStatisticsList"; $("#listshow").html(""); Haitai.Ajax.request({ url : url, params:{ token:token }, form : searchForm, callback : function(text){ closeLoading(); ht("listshow").html(text,false); } }); } function checkYhry(obj){ if(obj.value=="xmlb"&&obj.checked){ $("#yhry").attr("disabled",true); }else if(obj.value=="jtxm"&&obj.checked){ $("#yhry").attr("disabled",true); }else{ $("#yhry").attr("disabled",false); } } function checkTime(obj){ if(obj.value=="0"&&obj.checked){ $("#startTime").attr("disabled",true); $("#endTime").attr("disabled",true); $("#months").attr("disabled",false); }else{ $("#startTime").attr("disabled",false); $("#endTime").attr("disabled",false); $("#months").attr("disabled",true); } searchList(); } function checkIsNull(str){ if(str==null||str==""||str==undefined){ return true; }else{ return false; } } //选择科室联动变化医护人员下拉框数据,护士变,医生随科室切换变化 function changeYhry(obj){ var xzks00 = obj.value; if(xzks00!=""){ var url = "do?module=inpordnurse&action=YlzBqsrtj&method=searchYhryByXzks"; Haitai.Ajax.request({ url : url, params:{ token:token, xzks00:xzks00 }, form : searchForm, callback : function(text){ if(checkIsNull(text)){ var yhryObj = $("#yhry"); yhryObj.html(""); yhryObj.append($("<option selected=\"selected\" value=\"\">全部</option>")); }else{ var retJson = eval("("+text+")"); var yhryObj = $("#yhry"); yhryObj.html(""); yhryObj.append($("<option selected=\"selected\" value=\"\">全部</option>")); for(var i=0;i<retJson.length;i++){ yhryObj.append($("<option value=\""+retJson[i].ygbh00+"\">"+retJson[i].zwxm00+"</option>")); } } } }); } } function exportExcel(){ } </script> </html>exportExcel帮我导出excel
最新发布
07-16
### ### 方法一:通过设置响应头直接导出为 Excel 文件 在 JSP 页面中,可以通过设置 `response` 的内容类型和文件名来实现将页面内容导出为 Excel 文件。具体做法是将内容类型设为 `application/vnd.ms-excel` 或 `application/msexcel`,并设置 `Content-Disposition` 头以指定下载的文件名。 以下是一个示例代码片段: ```jsp <%@ page import="java.net.URLEncoder" %> <% String fileName = "项目费用计提计算表.xls"; response.setContentType("application/msexcel;charset=UTF-8"); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8")); %> ``` 此方法会将当前 JSP 页面的内容作为 Excel 文件进行下载。如果页面包含 HTML 表格(`<table>`),Excel 会尝试将其渲染为表格数据格式 [^1]。 --- ### ### 方法二:使用 Apache POI 动态生 Excel 文件 如果需要更复杂的 Excel 文件格式控制,例如样式、公式、多工作表等,则可以使用 Apache POI 库来动态生 Excel 文件,并将其写入到响应输出流中。这种方式适用于需要精确控制 Excel 格式的情况。 以下是基本实现步骤: 1. 引入 Apache POI 依赖(假设使用 Maven): ```xml <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>5.2.3</version> </dependency> ``` 2.JSP 中编写代码生 Excel 并输出: ```jsp <%@ page import="org.apache.poi.ss.usermodel.*, org.apache.poi.xssf.usermodel.XSSFWorkbook" %> <% Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet("Sheet1"); Row headerRow = sheet.createRow(0); Cell headerCell = headerRow.createCell(0); headerCell.setCellValue("名称"); headerCell = headerRow.createCell(1); headerCell.setCellValue("值"); for (int i = 1; i <= 10; i++) { Row row = sheet.createRow(i); row.createCell(0).setCellValue("项目 " + i); row.createCell(1).setCellValue(i * 100); } response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=data.xlsx"); ServletOutputStream outStream = response.getOutputStream(); workbook.write(outStream); workbook.close(); outStream.flush(); outStream.close(); %> ``` 这种方式允许开发者完全控制 Excel 内容,并支持 `.xlsx` 格式文件的导出 [^2]。 --- ### ### 方法三:前端 JavaScript 实现浏览器端复制粘贴到 Excel 对于简单的导出需求,可以在前端使用 JavaScript 将 HTML 表格内容复制到剪贴板,并调用 ActiveXObject 打开 Excel 并粘贴数据。这种方法适用于 Internet Explorer 浏览器环境: ```html <script type="text/javascript"> function exportToExcel() { var table = document.getElementById("dataTable"); var range = document.body.createTextRange(); range.moveToElementText(table); range.execCommand("Copy"); var excelApp = new ActiveXObject("Excel.Application"); excelApp.Visible = true; var workbook = excelApp.Workbooks.Add(); var worksheet = workbook.Worksheets.Item(1); worksheet.Paste(); } </script> ``` 此方法依赖户端安装了 Microsoft Excel,并且仅限于 Internet Explorer 使用 [^4]。 --- ### ### 注意事项 - **中文文件名编码**:在设置文件名时,应使用 `URLEncoder.encode()` 对文件名进行编码,以避免浏览器无法识别中文字符的问题。 - **兼容性问题**:同浏览器对 `Content-Disposition` 的解析可能略有差异,建议统一使用 UTF-8 编码处理文件名。 - **性能优化**:如果导出的数据量较大,推荐分页查询或使用异步加载机制,以避免服务器端内存溢出。 - **安全性考虑**:确保导出的数据经过权限验证,防止未经授权的数据访问。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值