首页 > 其他分享 >jsp实践

jsp实践

时间:2023-05-24 09:14:29浏览次数:43  
标签:String val 实践 session jsp str print out

equipmentList.jsp

<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.FileReader"%>
<%@page import="java.io.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="utf-8" %>
<html>
    <head>
        <title>Web程序设计作业2</title>
        <meta charset="utf-8">
        <script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="my_css.css">
        	<script type="text/javascript">
            function deleteRow(r)
            {
                var i = r.parentNode.parentNode.rowIndex;
              	//用户安全提示
       			if(confirm("您确定需要删除吗?"))
       			{
       				location.href="${pageContext.request.contextPath}/EquipmentDeleteServlet?delRow="+i;
       			}
            }
            function isRightTime(installationTime)
            {
                var i;
                if(installationTime.length<19)
                {
                    alert("输入的时间字符串过短!");
                    return 0;
                }
                /*下面是判断是否是数字*/
                for(i=0;i<=3;++i)if(installationTime[i]<'0'||installationTime[i]>'9')return 0;
                if(installationTime[4]!='-')return 0;
                for(i=5;i<=6;++i)if(installationTime[i]<'0'||installationTime[i]>'9')return 0;
                if(installationTime[7]!='-')return 0;
                for(i=8;i<=9;++i)if(installationTime[i]<'0'||installationTime[i]>'9')return 0;
                if(installationTime[10]!=' ')return 0;
                for(i=11;i<=12;++i)if(installationTime[i]<'0'||installationTime[i]>'9')return 0;
                if(installationTime[13]!=':')return 0;
                for(i=14;i<=15;++i)if(installationTime[i]<'0'||installationTime[i]>'9')return 0;
                if(installationTime[16]!=':')return 0;
                for(i=17;i<=18;++i)if(installationTime[i]<'0'||installationTime[i]>'9')return 0;
                if(installationTime.length>19)
                {
                    alert("输入的时间字符串过长!");
                    return 0;
                }
                
                var nian=0,yue=0,ri=0,shi=0,fen=0,miao=0;
                for(i=0;i<=3;++i)nian=nian*10+(installationTime[i]-'0');
                for(i=5;i<=6;++i)yue=yue*10+(installationTime[i]-'0');
                for(i=8;i<=9;++i)ri=ri*10+(installationTime[i]-'0');
                for(i=11;i<=12;++i)shi=shi*10+(installationTime[i]-'0');
                for(i=14;i<=15;++i)fen=fen*10+(installationTime[i]-'0');
                for(i=17;i<=18;++i)miao=miao*10+(installationTime[i]-'0');
                if(yue>12)
                {
                    alert("月份不能超过12!");
                    return 0;
                }
                if((yue==1||yue==3||yue==5||yue==7||yue==8||yue==10||yue==12)&&ri>31)
                {
                    alert("该月份日期不能超过31!");
                    return 0;
                }
                if((yue==4||yue==6||yue==9||yue==11)&&ri>30)
                {
                    alert("该月份日期不能超过30!");
                    return 0;
                }
                if(yue==2)
                {
                    if((nian%100!=0&&nian%4==0)||(nian%100==0&&nian%400==0))//闰年
                    {
                        if(ri>29)
                        {
                            alert("这一年2月日期不能超过29!");
                            return 0;
                        }
                    }
                    else
                    {
                        if(ri>28)
                        {
                            alert("这一年2月日期不能超过28!");
                            return 0;
                        }
                    }
                }
                if(shi>23)
                {
                    alert("小时不能超过23!");
                    return 0;
                }
                if(fen>59)
                {
                    alert("分钟不能超过59!");
                    return 0;
                }
                if(miao>59)
                {
                    alert("秒数不能超过59!");
                    return 0;
                }
                return 1;
            }
            function confirmInput1() 
            {
                if ( $("#equipmentName1").val() == null || $("#equipmentName1").val() == "" ) 
                {
                    alert("设备名称不能为空!");
                    $("#equipmentName1").focus();
                    return false;
                } 
                if ( $("#equipmentCode1").val() == null || $("#equipmentCode1").val() == "" ) 
                {
                    alert("设备编码不能为空!");
                    $("#equipmentCode1").focus();
                    return false;
                } 
                if ( $("#installationTime1").val() == null || $("#installationTime1").val() == "" ) 
                {
                    alert("安装时间不能为空!");
                    $("#installationTime1").focus();
                    return false;
                } 
                if ( isRightTime( $("#installationTime1").val() )==0) 
                {
                    alert("安装时间格式必须是yyyy-MM-dd HH:mm:ss");
                    $("#installationTime1").focus();
                    return false;
                } 
                
                if(confirm("您确定需要新增吗?"))
       			{
       				location.href="${pageContext.request.contextPath}/EquipmentAddServlet?siteName1="+$("#siteName1").val()
       						+"&equipmentName1="+$("#equipmentName1").val()
       						+"&equipmentCode1="+$("#equipmentCode1").val()
       						+"&equipmentCategory1="+$("#equipmentCategory1").val()
       						+"&equipmentType1="+$("#equipmentType1").val()
       						+"&installationTime1="+$("#installationTime1").val()
       						+"&equipmentStatus1="+$("#equipmentStatus1").val();	
       			}
                
                $("#siteName1").val("");
                $("#equipmentName1").val("");
                $("#equipmentCode1").val("");
                $("#equipmentCategory1").val("");
                $("#equipmentType1").val("");
                $("#installationTime1").val("");
                $("#equipmentStatus1").val("");
                return true;
            }
            function changeDispaly(r)
            {
                nowChangingRow = r.parentNode.parentNode.rowIndex;
                var table=document.getElementById("equipmentTable");
                var nowRow=table.rows[nowChangingRow].cells;
                //$("#changeTable").toggle();
                $("#changeTable").show();
                
                
                $("#siteName2").val(nowRow[0].innerHTML);
                $("#equipmentName2").val(nowRow[1].innerHTML);
                $("#equipmentCode2").val(nowRow[2].innerHTML);
                $("#equipmentCategory2").val(nowRow[3].innerHTML);
                $("#equipmentType2").val(nowRow[4].innerHTML);
                $("#installationTime2").val(nowRow[5].innerHTML);
                $("#equipmentStatus2").val(nowRow[6].innerHTML);
            }
            var nowChangingRow;
            function confirmInput2() 
            {
                if ( $("#equipmentName2").val() == null || $("#equipmentName2").val() == "" ) 
                {
                    alert("设备名称不能为空!");
                    $("#equipmentName2").focus();
                    return false;
                } 
                if ( $("#equipmentCode2").val() == null || $("#equipmentCode2").val() == "" ) 
                {
                    alert("设备编码不能为空!");
                    $("#equipmentCode2").focus();
                    return false;
                } 
                if ( $("#installationTime2").val() == null || $("#installationTime2").val() == "" ) 
                {
                    alert("安装时间不能为空!");
                    $("#installationTime2").focus();
                    return false;
                } 
                if ( isRightTime( $("#installationTime2").val() )==0) 
                {
                    alert("安装时间格式必须是yyyy-MM-dd HH:mm:ss");
                    $("#installationTime2").focus();
                    return false;
                } 
                
                
                if(confirm("您确定需要修改吗?"))
       			{
       				location.href="${pageContext.request.contextPath}/EquipmentEditServlet?siteName2="+$("#siteName2").val()
       						+"&equipmentName2="+$("#equipmentName2").val()
       						+"&equipmentCode2="+$("#equipmentCode2").val()
       						+"&equipmentCategory2="+$("#equipmentCategory2").val()
       						+"&equipmentType2="+$("#equipmentType2").val()
       						+"&installationTime2="+$("#installationTime2").val()
       						+"&equipmentStatus2="+$("#equipmentStatus2").val()
       						+"&changeRow="+nowChangingRow;
       			}
                $("#changeTable").hide();
                return true;
            }

            

            $(function() //初始化
            {
                $("#changeTable").toggle();
            });

            
            </script>
        </link>

    </head>

    <body>
        <table id="equipmentTable" border="1">
            <caption>设备信息</caption>
            <thead>
                <tr>
                    <th>站点名称</th><th>设备名称</th><th>设备编码</th><th>设备分类</th><th>设备类型</th><th>安装时间</th><th>设备状态</th><th>操作</th>
                </tr>
					<%
						String path=application.getRealPath("");
						File file = new File(path,"equipments.txt");
						FileInputStream ch = new FileInputStream(file);
						InputStreamReader fr = new InputStreamReader(ch,"UTF-8");  //字符输入流	编码转换
						BufferedReader br = new BufferedReader(fr);  //使文件可按行读取并具有缓冲功能
						String str = br.readLine();	
						while(str!=null)
						{	
							out.print("<tr><td>");
							for(int i=0;i<str.length();++i)
							{
								if(str.charAt(i)==' '&&str.charAt(i-3)!='-')
								{
									out.print("</td><td>");
								}
								else
								{
									out.print(str.charAt(i));
								}
							}
							out.print("</td><td><a href='#' onclick='changeDispaly(this);'>修改</a> <a href='#' onclick='deleteRow(this);'>删除</a></td></tr>");
							str = br.readLine();	
						}	
						br.close();    //关闭输入流	
					%>     	
            </thead>
        </table>


        <form method="post" id="addTable">
            <fieldset>
            <legend>新增</legend>
            站点名称(*):
                    <select id="siteName1" name="siteName1">  
                    <option value="昌都生态监测站">昌都生态监测站</option>
                    <option value="申扎生态监测站">申扎生态监测站</option>
                    <option value="日喀则生态监测站">日喀则生态监测站</option>
                    </select>
                    <br />  
            设备名称(*):<input type="text" value="" id="equipmentName1" name="equipmentName1"><br /> 
            设备编码(*):<input type="text" value="" id="equipmentCode1" name="equipmentCode1"><br />
            设备分类(*):
                    <select id="equipmentCategory1" name="equipmentCategory1">  
                    <option value="土壤">土壤</option>
                    <%
                    	for(int i=1;i<=10;++i)out.print("<option value='1'>"+i+"</option>");
					%> 
                    </select>
                    <br /> 
            设备类型(*):
                    <select id="equipmentType1" name="equipmentType1">  
                    <option value="冻土检测">冻土检测</option>
                    <%
                    	for(int i=1;i<=10;++i)out.print("<option value='1'>"+i+"</option>");
					%> 
                    </select>
                    <br /> 
            安装时间(*):<input type="text" value="" id="installationTime1" name="installationTime1"><br /><br /> 
            设备状态(*)
                    <select id="equipmentStatus1" name="equipmentStatus1">  
                    <option value="正常">正常</option>
                    <option value="异常">异常</option>
                    </select>
                    <br /> 
                <input type="button" id="button1" value="确定" onclick="confirmInput1();" />
            </fieldset>
        </form>
		<form method="POST" id="changeTable">
            <fieldset>
            <legend>修改</legend>
            站点名称(*):
                    <select id="siteName2">  
                    <option value="昌都生态监测站">昌都生态监测站</option>
                    <option value="申扎生态监测站">申扎生态监测站</option>
                    <option value="日喀则生态监测站">日喀则生态监测站</option>
                    </select>
                    <br />  
            设备名称(*):<input type="text" value="" id="equipmentName2"><br /> 
            设备编码(*):<input type="text" value="" id="equipmentCode2"><br />
            设备分类(*):
                    <select id="equipmentCategory2">  
                    <option value="土壤">土壤</option>
                    <%
                    	for(int i=1;i<=10;++i)out.print("<option value='1'>"+i+"</option>");
					%> 
                    </select>
                    <br /> 
            设备类型(*):
                    <select id="equipmentType2">  
                    <option value="冻土检测">冻土检测</option>
                    <%
                    	for(int i=1;i<=10;++i)out.print("<option value='1'>"+i+"</option>");
					%> 
                    </select>
                    <br /> 
            安装时间(*):<input type="text" value="" id="installationTime2"><br /><br /> 
            设备状态(*)
                    <select id="equipmentStatus2">  
                    <option value="正常">正常</option>
                    <option value="异常">异常</option>
                    </select>
                    <br /> 
                <input type="button" id="button2" value="确定" onclick="confirmInput2();" />
            </fieldset>
        </form>


    </body>

</html>

EquipmentAddServlet.java

package myServlet;

import java.io.*;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebServlet("/EquipmentAddServlet")
public class EquipmentAddServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public EquipmentAddServlet() 
    {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		HttpSession session = request.getSession();
			
		request.setCharacterEncoding("utf-8");
		String siteName1=request.getParameter("siteName1");
		String equipmentName1=request.getParameter("equipmentName1");
		String equipmentCode1=request.getParameter("equipmentCode1");
		String equipmentCategory1=request.getParameter("equipmentCategory1");
		String equipmentType1=request.getParameter("equipmentType1");
		String installationTime1=request.getParameter("installationTime1");
		String equipmentStatus1=request.getParameter("equipmentStatus1");
		
		Integer cntAdd=(Integer)(session.getAttribute("cntAdd"));
		if(cntAdd==null)cntAdd=new Integer(0);
		cntAdd=cntAdd+1;
		session.setAttribute("cntAdd",cntAdd);
		session.setAttribute("siteNameAdd"+cntAdd.toString(),siteName1);
		session.setAttribute("equipmentNameAdd"+cntAdd.toString(),equipmentName1);
		session.setAttribute("equipmentCodeAdd"+cntAdd.toString(),equipmentCode1);
		session.setAttribute("equipmentCategoryAdd"+cntAdd.toString(),equipmentCategory1);
		session.setAttribute("equipmentTypeAdd"+cntAdd.toString(),equipmentType1);
		session.setAttribute("installationTimeAdd"+cntAdd.toString(),installationTime1);
		session.setAttribute("equipmentStatusAdd"+cntAdd.toString(),equipmentStatus1);
		
		ServletContext context = getServletContext();
		String path = context.getRealPath("/equipments.txt");
		File file = new File(path);
		
		FileInputStream fis = new FileInputStream(file);
		InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
		BufferedReader br = new BufferedReader(isr); 
			
		int cnt=1;
		String []tmp=new String[105];
		tmp[1] = br.readLine();
		while(tmp[cnt]!=null)
		{	
			tmp[++cnt] = br.readLine();
		}	
		br.close();
		FileOutputStream fos = new FileOutputStream(file);
		OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
		BufferedWriter bw = new BufferedWriter(osw);
		for(int i=1;i<cnt;++i)bw.write(tmp[i]+"\n");
		bw.write(siteName1+" "+equipmentName1+" "+equipmentCode1+" "+equipmentCategory1+" "+equipmentType1+" "+installationTime1+" "+equipmentStatus1);
		bw.close();
		response.sendRedirect(request.getHeader("referer"));
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

EquipmentDeleteServlet.java

package myServlet;

import java.io.*;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebServlet("/EquipmentDeleteServlet")
public class EquipmentDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public EquipmentDeleteServlet() 
    {
        super();
    }
    int Pos,Row;
    String []tmp=new String[105];
    public String myRead(int beginPos)
    {
    	String t=new String("");
    	for(int i=beginPos;i<tmp[Row].length();++i)
    	{
    		Pos=i;
    		if(tmp[Row].charAt(i)==' '&&tmp[Row].charAt(i-3)!='-')break;
    		t=t+tmp[Row].charAt(i);
    	}
		return t;
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		
		HttpSession session = request.getSession();
		request.setCharacterEncoding("utf-8");
		String delRow=request.getParameter("delRow");
		
		ServletContext context = getServletContext();
		String path = context.getRealPath("/equipments.txt");
		File file = new File(path);	
		
		FileInputStream fis = new FileInputStream(file);
		InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
		BufferedReader br = new BufferedReader(isr);		
		
		int cnt=1;
		tmp[1] = br.readLine();
		while(tmp[cnt]!=null)
		{	
			tmp[++cnt] = br.readLine();
		}	
		br.close();
		FileOutputStream fos = new FileOutputStream(file);
		OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
		BufferedWriter bw = new BufferedWriter(osw);
		for(int i=1;i<cnt;++i)
			if(i!=Integer.parseInt(delRow))bw.write(tmp[i]+"\n");
		
		Integer cntDelete=(Integer)(session.getAttribute("cntDelete"));
		if(cntDelete==null)cntDelete=new Integer(0);
		cntDelete=cntDelete+1;
		Pos=-1;Row=Integer.parseInt(delRow);
		
		String siteName1=myRead(Pos+1);
		String equipmentName1=myRead(Pos+1);
		String equipmentCode1=myRead(Pos+1);
		String equipmentCategory1=myRead(Pos+1);
		String equipmentType1=myRead(Pos+1);
		String installationTime1=myRead(Pos+1);
		String equipmentStatus1=myRead(Pos+1);
		session.setAttribute("cntDelete",cntDelete);
		session.setAttribute("siteNameDelete"+cntDelete.toString(),siteName1);
		session.setAttribute("equipmentNameDelete"+cntDelete.toString(),equipmentName1);
		session.setAttribute("equipmentCodeDelete"+cntDelete.toString(),equipmentCode1);
		session.setAttribute("equipmentCategoryDelete"+cntDelete.toString(),equipmentCategory1);
		session.setAttribute("equipmentTypeDelete"+cntDelete.toString(),equipmentType1);
		session.setAttribute("installationTimeDelete"+cntDelete.toString(),installationTime1);
		session.setAttribute("equipmentStatusDelete"+cntDelete.toString(),equipmentStatus1);
		
		bw.close();
		response.sendRedirect(request.getHeader("referer"));
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

EquipmentEditServlet.java

package myServlet;

import java.io.*;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebServlet("/EquipmentEditServlet")
public class EquipmentEditServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public EquipmentEditServlet() 
    {
        super();
    }
    int Pos,Row;
    String []tmp=new String[105];
    public String myRead(int beginPos)
    {
    	String t=new String("");
    	for(int i=beginPos;i<tmp[Row].length();++i)
    	{
    		Pos=i;
    		if(tmp[Row].charAt(i)==' '&&tmp[Row].charAt(i-3)!='-')break;
    		t=t+tmp[Row].charAt(i);
    	}
		return t;
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		HttpSession session = request.getSession();
		request.setCharacterEncoding("utf-8");
		String changeRow=request.getParameter("changeRow");
		String siteName2=request.getParameter("siteName2");
		String equipmentName2=request.getParameter("equipmentName2");
		String equipmentCode2=request.getParameter("equipmentCode2");
		String equipmentCategory2=request.getParameter("equipmentCategory2");
		String equipmentType2=request.getParameter("equipmentType2");
		String installationTime2=request.getParameter("installationTime2");
		String equipmentStatus2=request.getParameter("equipmentStatus2");
		
		ServletContext context = getServletContext();
		String path = context.getRealPath("/equipments.txt");
		File file = new File(path);
		
		
		FileInputStream fis = new FileInputStream(file);
		InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
		BufferedReader br = new BufferedReader(isr);
		
		
		
		int cnt=1;
		tmp[1] = br.readLine();
		while(tmp[cnt]!=null)
		{	
			tmp[++cnt] = br.readLine();
		}	
		br.close();
		FileOutputStream fos = new FileOutputStream(file);
		OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
		BufferedWriter bw = new BufferedWriter(osw);
		for(int i=1;i<cnt;++i)
			if(i!=Integer.parseInt(changeRow))bw.write(tmp[i]+"\n");
			else bw.write(siteName2+" "+equipmentName2+" "+equipmentCode2+" "+equipmentCategory2+" "+equipmentType2+" "+installationTime2+" "+equipmentStatus2+"\n");
		
		
		Integer cntChange=(Integer)(session.getAttribute("cntChange"));
		if(cntChange==null)cntChange=new Integer(0);
		cntChange=cntChange+1;
		Pos=-1;Row=Integer.parseInt(changeRow);
		
		String siteName1=myRead(Pos+1);
		String equipmentName1=myRead(Pos+1);
		String equipmentCode1=myRead(Pos+1);
		String equipmentCategory1=myRead(Pos+1);
		String equipmentType1=myRead(Pos+1);
		String installationTime1=myRead(Pos+1);
		String equipmentStatus1=myRead(Pos+1);
		session.setAttribute("cntChange",cntChange);
		session.setAttribute("siteNameChangeBefore"+cntChange.toString(),siteName1);
		session.setAttribute("equipmentNameChangeBefore"+cntChange.toString(),equipmentName1);
		session.setAttribute("equipmentCodeChangeBefore"+cntChange.toString(),equipmentCode1);
		session.setAttribute("equipmentCategoryChangeBefore"+cntChange.toString(),equipmentCategory1);
		session.setAttribute("equipmentTypeChangeBefore"+cntChange.toString(),equipmentType1);
		session.setAttribute("installationTimeChangeBefore"+cntChange.toString(),installationTime1);
		session.setAttribute("equipmentStatusChangeBefore"+cntChange.toString(),equipmentStatus1);
		
		session.setAttribute("siteNameChangeAfter"+cntChange.toString(),siteName2);
		session.setAttribute("equipmentNameChangeAfter"+cntChange.toString(),equipmentName2);
		session.setAttribute("equipmentCodeChangeAfter"+cntChange.toString(),equipmentCode2);
		session.setAttribute("equipmentCategoryChangeAfter"+cntChange.toString(),equipmentCategory2);
		session.setAttribute("equipmentTypeChangeAfter"+cntChange.toString(),equipmentType2);
		session.setAttribute("installationTimeChangeAfter"+cntChange.toString(),installationTime2);
		session.setAttribute("equipmentStatusChangeAfter"+cntChange.toString(),equipmentStatus2);
		
		bw.close();
		response.sendRedirect(request.getHeader("referer"));
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

OperLists.jsp

<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.FileReader"%>
<%@page import="java.io.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="utf-8" %>
<html>
    <head>
        <title>历史操作信息</title>
        <meta charset="utf-8">
        <script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="my_css.css">
        	<script type="text/javascript">
            
            
            </script>
        </link>

    </head>

    <body>
    	<table id="123" border="1">
    		<caption>新增设备列表</caption>
			<tr>
	        	<th>站点名称</th><th>设备名称</th><th>设备编码</th><th>设备分类</th><th>设备类型</th><th>安装时间</th><th>设备状态</th>
	        </tr>
			<%
				Integer cntAdd=(Integer)(session.getAttribute("cntAdd"));
				if(cntAdd==null)cntAdd=new Integer(0);
				for(int i=1;i<=cntAdd.intValue();++i)
				{
					out.print("<tr>");
					String str=(String)(session.getAttribute("siteNameAdd"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentNameAdd"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCodeAdd"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCategoryAdd"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentTypeAdd"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("installationTimeAdd"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentStatusAdd"+i));
					out.print("<td>"+str+"</td>");
					out.print("</tr>");
				}
			%>
		</table>
		<table id="equipmentTable" border="1">
	    	<caption>修改设备列表</caption>
			<tr>
	        	<th>站点名称</th><th>设备名称</th><th>设备编码</th><th>设备分类</th><th>设备类型</th><th>安装时间</th><th>设备状态</th><th>版本</th>
	        </tr>
			<%
			
				Integer cntChange=(Integer)(session.getAttribute("cntChange"));
				if(cntChange==null)cntChange=new Integer(0);
				for(int i=1;i<=cntChange.intValue();++i)
				{
					out.print("<tr>");
					String str=(String)(session.getAttribute("siteNameChangeBefore"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentNameChangeBefore"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCodeChangeBefore"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCategoryChangeBefore"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentTypeChangeBefore"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("installationTimeChangeBefore"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentStatusChangeBefore"+i));
					out.print("<td>"+str+"</td>");
					out.print("<td>"+"旧值"+"</td>");
					out.print("</tr>");
					
					out.print("<tr>");
					str=(String)(session.getAttribute("siteNameChangeAfter"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentNameChangeAfter"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCodeChangeAfter"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCategoryChangeAfter"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentTypeChangeAfter"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("installationTimeChangeAfter"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentStatusChangeAfter"+i));
					out.print("<td>"+str+"</td>");
					out.print("<td>"+"新值"+"</td>");
					out.print("</tr>");
				}
				
			%>
		</table>
		<table id="equipmentTable" border="1">
	    	<caption>删除设备列表</caption>
			<tr>
	        	<th>站点名称</th><th>设备名称</th><th>设备编码</th><th>设备分类</th><th>设备类型</th><th>安装时间</th><th>设备状态</th>
	        </tr>
			<%
				Integer cntDelete=(Integer)(session.getAttribute("cntDelete"));
				if(cntDelete==null)cntDelete=new Integer(0);
				for(int i=1;i<=cntDelete.intValue();++i)
				{
					out.print("<tr>");
					String str=(String)(session.getAttribute("siteNameDelete"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentNameDelete"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCodeDelete"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentCategoryDelete"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentTypeDelete"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("installationTimeDelete"+i));
					out.print("<td>"+str+"</td>");
					str=(String)(session.getAttribute("equipmentStatusDelete"+i));
					out.print("<td>"+str+"</td>");
					out.print("</tr>");
				}
			%>
		</table>
    </body>

</html>

标签:String,val,实践,session,jsp,str,print,out
From: https://www.cnblogs.com/wljss/p/17426981.html

相关文章

  • ESM风潮下企业服务的最佳实践探讨
    甄知科技孵化于中国领先的IT咨询服务提供商-上海汉得信息技术股份有限公司,主打产品“燕千云”于2019年正式发布,持续迭代版本至今,燕千云作为企业数字化服务平台,燕千云的愿景和现状是为了帮助企业服务团队快速解决问题、优化服务流程、提高服务效率和服务质量,全面满足企业业务运营......
  • RocketMQ 在小米的多场景灾备实践案例
    作者:邓志文、王帆01为什么要容灾?在小米内部,我们使用RocketMQ来为各种在线业务提供消息队列服务,比如商城订单、短信通知甚至用来收集IoT设备的上报数据,可以说RocketMQ的可用性就是这些在线服务的生命线。作为软件开发者,我们通常希望服务可以按照理想状态去运行:在没有Bug的......
  • 建设一站式DevOps平台,腾讯云研发效能提升实践
    本文作者:张渝导语|近年来,研发效能提升越来越受到业界重视,许多厂商都在不断探索研发效能提升之路,从而实现研发效率和质量的持续优化,以应对日趋复杂的产品开发。那么腾讯云的研发效能相关工作是如何开展和落地的呢?今天我们特邀了腾讯云研发效能工作组负责人、腾讯健康副总裁张......
  • 万亿级大数据监控平台建设实践
    1整体设计在整体监控设计中,百分点大数据团队采用“去中心化”、“服务透明化”的设计思路,同时具备极强的扩展能力、自动化能力和高可靠性设计思路。 去中心化设计:由于要同时监控18个异地的数据中心,开始百分点大数据团队考虑过18个中心各自监控,但是整体性差、不直观且维......
  • 企业敏捷开发的三种落地实践途径
    随着互联网科技的飞速发展,数字化浪潮正冲击着每一家企业,软件开发成为了企业数字化转型中的核心问题。面对着近年来的疫情、国内政策导向调整和经济转型等一系列重大事件,企业面对着全世界最动态、最复杂、演化最快及不确定性最高的市场环境,因此降本增效,实现敏捷开发是数字化转型的必......
  • 北京站丨云原生技术实践营邀请您参加!
    活动简介云原生(CloudNative)作为云计算的再升级,已经成为新的发展热点。随着新的技术发展,云原生的概念在不断的演化,各行各业的IT架构转型历程也是伴随云原生技术发展逐步演进,从探索云计算、分布式等新技术的规模化运用,到加速云原生布局,全面落地云原生技术,构建云原生生态。本期......
  • 成长笔记二、MySQL数据库--学生管理系统数据库手写SQL实现(实践篇)
    学生对象---->学生表(student)老师对象---->老师表(teacher)课程对象---->课程表(course)成绩对象---->成绩表(score)班级对象---->班级表(前缀_class,因为user或class等英文单词是程序中的关键字.尽量不直接用)等.....数据库设计设计参考上篇博客https://ww......
  • Seata 的可观测实践
    作者:察溯Seata简介Seata的前身是阿里巴巴集团内大规模使用保证分布式事务一致性的中间件,Seata是其开源产品,由社区维护。在介绍Seata前,先与大家讨论下我们业务发展过程中经常遇到的一些问题场景。业务场景我们业务在发展的过程中,基本上都是从一个简单的应用,逐渐过渡到规模......
  • 【实践篇】领域驱动设计:DDD工程参考架构
    背景为什么要制定参考工程架构不同团队落地DDD所采取的应用架构风格可能不同,并没有统一的、标准的DDD工程架构。有些团队可能遵循经典的DDD四层架构,或改进的DDD四层架构,有些团队可能综合考虑分层架构、整洁架构、六边形架构等多种架构风格,有些在实践中可能引入CQRS解决读模型与......
  • web Service实践——Xfire的ws-security用户名和密码安全验证
    一、参照《WebService实践之——XFire实例》(本空间的文章)建立一个Xfire的应用;二、引入的jar包:xfire-1.2.6的所有jar包(包括xfire-all-1.2.6.jar),下载地址:http://xfire.codehaus.org/Downloadwss4j-1.5.8.jar:下载地址:http://ws.apache.org/wss4j/三、服务器端1、PasswordHandler类,继......