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)>
    

      

      

     

  • 相关阅读:
    针对Ext js的分页存储过程适用于sqlserver2008
    30分钟LINQ教程
    windows server 2003 sp2安装VS2010之后需要打的几个布丁
    【翻译】Prism4:初始化Prism应用程序(上)
    ASP.NET WebAPI 路由规则与POST数据
    基于.net开发chrome核心浏览器【二】
    六种SQL Server删除重复行的方法
    Web在线操作Office文件 (转)
    ASP.NET 中如何对生成的 HTML 内容流进行控制?
    使用键值表实现通用流水号(转)
  • 原文地址:https://www.cnblogs.com/wujixing/p/5287589.html
Copyright © 2011-2022 走看看