This article introduces a simple example code of a jsp file about key query. Friends who need it can refer to it
This is a jsp file about key query, which accepts the data of the superior file and encrypts it. Process, put it into the Map collection, and submit it to the xdoc file through the form form; however, this approach is to meet the company's requirements, and the content of the framework is inevitably cumbersome; the next article will introduce a simple method that does not require too much construction. Common practice in multiple environments.
<br><br><%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@page import="java.io.IOException"%> <%@page import="java.util.ArrayList"%> <%@page import="java.util.List"%> <%@page import="java.util.HashMap"%> <%@page import="java.util.Map"%> <%@page import="java.sql.*"%> <%@page import="java.util.*"%> <%@page import="java.sql.ResultSet"%> <%@page import="combiz.system.IBOSrvUtil"%> <%@page import="combiz.ui.epassmanager.entitys.Base64"%> <%@ include file="xdocserver.jsp" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String xdocserver1 = EjbServerName.getValue("xdocserver"); System.out.println("basePath basePath==========================="+basePath); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <% StringBuffer sb=new StringBuffer(); String part = request.getParameter("szbm"); String str1=new String(part.getBytes("ISO-8859-1"),"GBK"); String sta = request.getParameter("syzt"); String str2=new String(sta.getBytes("ISO-8859-1"),"GBK"); String tems1 = ""; if(str2.equals("正在使用")){ tems1="use"; }else if(str2.equals("暂停使用")){ tems1="pause"; }else if(str2.equals("停止使用")){ tems1="stop"; } else{ tems1="use"; } String s1 = Base64.encodeFixLenString(tems1); String sql=""; List menuList=new ArrayList(); sql =" select t.companyid ,a.laborname ,t.keysn ,t.keystatus from sys_key t "+ " left join IBSUSERS b on b.id = t.id left join labor a on a.labornum = b.labornum where 1=1 "; if(!str1.equals("")){ sql +=" and t.companyid like '%"+str1+"%' "; } if(!s1.equals("")){ sql +=" and t.keystatus = '"+s1+"'"; } try { List list = IBOSrvUtil.getBaseDao().selectListBySql(sql); sb.append("<xdata>"); if(list.size()>0){ for(int i=0;i<list.size();i++){ Map map = (Map) list.get(i); sb.append("<row>"); String keysn=Base64.decodeToFixLenString(map.get("KEYSN")==null?"":map.get("KEYSN").toString()); String laborname=map.get("LABORNAME")==null?"":map.get("LABORNAME").toString(); String companyid=map.get("COMPANYID")==null?"":map.get("COMPANYID").toString(); String temstatus =Base64.decodeToFixLenString(map.get("KEYSTATUS")==null?"":map.get("KEYSTATUS").toString()); Map<String, String> compMap = new HashMap<String, String>(); String status = ""; if(temstatus.equals("use")){ status="正在使用"; }else if(temstatus.equals("pause")){ status="暂停使用"; }else{ status="停止使用"; } sb.append("<col1>").append(keysn).append("</col1>"); sb.append("<col2>").append(laborname).append("</col2>"); sb.append("<col3>").append(companyid).append("</col3>"); sb.append("<col4>").append(status).append("</col4>"); sb.append("</row>"); } } sb.append("</xdata>"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("sb===null=============="+sb); %> <iframe name="xdoc" width="100%" height="100%"></iframe> <form name="form1" action="http://11.1.1.152:8088/xdoc/realty/mycx.xdoc" method="post" target="xdoc" style="display: none"> <input name="data" type="hidden" value="<%=sb.toString()%>" /> </form> </body> <script language="javascript"> document.form1.submit(); </script> <script type="text/javascript"> function dosubmit(){ document.getElementById("btnSub").disabled = true; if(document.getElementById("szbm" ).value!="" || document.getElementById("syzt" ).value!="" ) { var f1 = document.getElementById("b1"); f1.submit(); } else{ alert("请输入查询条件!"); document.getElementById("btnSub").disabled = false; return ; } } //如果这三个条件同时为空的话就弹出提示框。否则执行F1并提交F1.就是得到的B1 </html>
The above is the detailed content of Detailed explanation of examples of data encryption and decryption in java. For more information, please follow other related articles on the PHP Chinese website!