zoukankan      html  css  js  c++  java
  • dashboard项目心得:

    DAO类实现查找数据并放入一个map

    public Map<String,Integer> getAllBlock_multi(String projectname)
    {  
      LinkedHashMap <String,Integer> map=new LinkedHashMap<String,Integer>();
      List<String> listTotal=new ArrayList<String>();   Connection conn=null;   Statement stmt=null;   ResultSet rs=null;
      projectname=projectname.replace(",","|");

      try{
          conn=Conn.getConnection();
          stmt=conn.createStatement();
          String sql="select Component, sum(Total) as Total, sum(COUNT) as COUNT from block_total where ProjectName REGEXP '"+projectname+"' group by Component order by Total desc,Component";
          rs=stmt.executeQuery(sql);
          while(rs.next())
          {
            map.put(rs.getString("Component"), rs.getInt("COUNT"));
          }
      }
      catch(Exception ex)
      {
        ex.printStackTrace();
      }
      
    finally
      
    {
        
    try
        {
          
    if(rs!=null)
          {
            rs.close();
            
    rs=null;
          
    }
          if(stmt!=null)
          {
            stmt.close();
            
    stmt=null;
          }
          
    if(conn!=null)
          {
            
    conn.close();
            conn=null;
          
    }
        }

        catch(Exception e)
        {
          e.printStackTrace();
        }
      }
      return map;
    }


         

     

    Acti  

    Map<String,Integer> map2= dad.getAllBlock_multi(pn);  
    List<String> listBlock1=new ArrayList<String>();   List<String> listBlock2=new ArrayList<String>(); Set<String> keysBlock=map2.keySet(); Iterator<String> iterBlock1=keysBlock.iterator(); while(iterBlock1.hasNext()){ listBlock1.add(iterBlock1.next()); } Collection<Integer> valuesBlock=map2.values(); Iterator<Integer> iterBlock2=valuesBlock.iterator(); while(iterBlock2.hasNext()){ listBlock2.add(iterBlock2.next()+""); }   request.put("BlockItem1", listBlock1.get(0).replace("Closed", "")); request.put("BlockItem2", listBlock1.get(4).replace("Closed", "")); //....................
              request.put("BlockClose1", listBlock2.get(0));

     

    动态刷新页面 从第N页跳转到别的页面, 返回的时候, 还回到原来页面的方法:

    1. index.jsp页面设置超链接时添加当前页面码数:

     

    html = html+ "<tr><td>"
      +person[i].getElementsByTagName("pid")[0].firstChild.data+"</td><td><a href=login_success.jsp?cur="+currpage+">"
      +person[i].getElementsByTagName("pname")[0].firstChild.data+"</a></td><td>"
      +person[i].getElementsByTagName("age")[0].firstChild.data
      +"</td></tr>";
    

    2. 跳转页面获取参数并设置超链接时把参数再传回去:

    <a href="index.jsp?c=<%=request.getParameter("cur")%>">登陆成功</a>
    

    3. 首页获取后, 变量取得作为显示页面的函数参数:

    <script>   	
    	var t;
    	t=(<%=request.getParameter("c")%>==null)?1:<%=request.getParameter("c")%>;	
    </script>  
    
    <body onLoad=AjaxTest(t)>
    

      

      

     

  • 相关阅读:
    powerview使用小记
    OPENWRT自动检测断线脚本
    openwrt路由在中继模式下掉线检测重启脚本
    OPENWRT断网自动关闭WIFI脚本
    jsp <li>中的多个input怎么换行
    联想笔记本G480怎么安装双系统?
    Java中List集合与Set集合
    JS中onfocus()事件,onblur()事件,onload()事件
    java之Date(日期)、Date格式化、Calendar(日历)
    如何一条SQL语句就能统计出多个表中某数据的数量?
  • 原文地址:https://www.cnblogs.com/wujixing/p/5287589.html
Copyright © 2011-2022 走看看