tinguo002

           

          js判斷數字-正則表達式(轉)

          http://blog.sina.com.cn/s/blog_72b7a82d0100yfip.html

          "^\\d+$"  //非負整數(正整數  0)   


          "^[0-9]*[1-9][0-9]*$"  //正整數   


          "^((-\\d+)|(0+))$"  //非正整數(負整數  0)   


          "^-[0-9]*[1-9][0-9]*$"  //負整數   


          "^-?\\d+$"    //整數   


          "^\\d+(\\.\\d+)?$"  //非負浮點數(正浮點數  0)   



          "^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$"  //正浮點數
           


          "^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$"  //非正浮點數(負浮點數  0)
           



          "^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"  //負浮點數
           


          "^(-?\\d+)(\\.\\d+)?$"  //浮點數



          測試:


          <script>


          function forcheck(ss){


          var
          type="^[0-9]*[1-9][0-9]*$";

          var re = new
          RegExp(type);

          if(ss.match(re)==null)

          {
          alert(
          "請輸入大于零的整數!");

          return;
            }


          }


          </script>

          posted @ 2013-07-04 17:59 一堣而安 閱讀(228) | 評論 (0)編輯 收藏

          ArrayList的toArray(轉)


          http://www.cnblogs.com/ihou/archive/2012/05/10/2494578.html

          ArrayList提供了一個將List轉為數組的一個非常方便的方法toArray。toArray有兩個重載的方法:

          1.list.toArray();

          2.list.toArray(T[]  a);

          對于第一個重載方法,是將list直接轉為Object[] 數組;

          第二種方法是將list轉化為你所需要類型的數組,當然我們用的時候會轉化為與list內容相同的類型。

          不明真像的同學喜歡用第一個,是這樣寫:

          1
          2
          3
          4
          5
          6
          7
          ArrayList<String> list=new ArrayList<String>();
                  for (int i = 0; i < 10; i++) {
                      list.add(""+i);
                  }
                 
                  String[] array= (String[]) list.toArray();
                

          結果一運行,報錯:

          Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;

          原因一看就知道了,不能將Object[] 轉化為String[].轉化的話只能是取出每一個元素再轉化,像這樣:

          1
          2
          3
          4
          5
          Object[] arr = list.toArray();
                  for (int i = 0; i < arr.length; i++) {
                      String e = (String) arr[i];
                      System.out.println(e);
                  }

          所以第一個重構方法就不是那么好使了。

          實際上,將list世界轉化為array的時候,第二種重構方法更方便,用法如下:

          1
          2
          String[] array =new String[list.size()];
                  list.toArray(array);<br><br>另附,兩個重構方法的源碼:

          1.
          public Object[] toArray(); {
          Object[] result = new Object[size];
          System.arraycopy(elementData, 0, result, 0, size);;
          return result;
          }

          2.

          public Object[] toArray(Object a[]); {
          if (a.length < size);
          a = (Object[]);java.lang.reflect.Array.newInstance(
          a.getClass();.getComponentType();, size);;
          System.arraycopy(elementData, 0, a, 0, size);;

          if (a.length > size);
          a[size] = null;

          return a;
          }

          1
          <br><br>
          1
          2
          <br>
            

          posted @ 2013-07-04 11:52 一堣而安 閱讀(255) | 評論 (0)編輯 收藏

          js獲取項目根路徑[轉]



          http://www.cnblogs.com/linjiqin/archive/2011/03/07/1974800.html
          //
          js獲取項目根路徑,如: http://localhost:8083/uimcardprj
          function getRootPath(){
              
          //獲取當前網址,如: http://localhost:8083/uimcardprj/share/meun.jsp
              var curWwwPath=window.document.location.href;
              
          //獲取主機地址之后的目錄,如: uimcardprj/share/meun.jsp
              var pathName=window.document.location.pathname;
              
          var pos=curWwwPath.indexOf(pathName);
              
          //獲取主機地址,如: http://localhost:8083
              var localhostPaht=curWwwPath.substring(0,pos);
              
          //獲取帶"/"的項目名,如:/uimcardprj
              var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
              
          return(localhostPaht+projectName);
          }

          posted @ 2013-06-19 16:14 一堣而安 閱讀(614) | 評論 (0)編輯 收藏

          轉]Java中HashMap遍歷的兩種方式

          轉]Java中HashMap遍歷的兩種方式
          原文地址: http://www.javaweb.cc/language/java/032291.shtml

          第一種:
            Map map = new HashMap();
            Iterator iter = map.entrySet().iterator();
            while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            Object key = entry.getKey();
            Object val = entry.getValue();
            }
            效率高,以后一定要使用此種方式!
          第二種:
            Map map = new HashMap();
            Iterator iter = map.keySet().iterator();
            while (iter.hasNext()) {
            Object key = iter.next();
            Object val = map.get(key);
            }
            效率低,以后盡量少使用!
           
                 HashMap的遍歷有兩種常用的方法,那就是使用keyset及entryset來進行遍歷,但兩者的遍歷速度是有差別的,下面請看實例:
            public class HashMapTest {
            public static void main(String[] args) ...{
            HashMap hashmap = new HashMap();
            for (int i = 0; i < 1000; i ) ...{
            hashmap.put("" i, "thanks");
            }
            long bs = Calendar.getInstance().getTimeInMillis();
            Iterator iterator = hashmap.keySet().iterator();
            while (iterator.hasNext()) ...{
            System.out.print(hashmap.get(iterator.next()));
            }
            System.out.println();
            System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
            listHashMap();
            }
            public static void listHashMap() ...{
            java.util.HashMap hashmap = new java.util.HashMap();
            for (int i = 0; i < 1000; i ) ...{
            hashmap.put("" i, "thanks");
            }
            long bs = Calendar.getInstance().getTimeInMillis();
            java.util.Iterator it = hashmap.entrySet().iterator();
            while (it.hasNext()) ...{
            java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
            // entry.getKey() 返回與此項對應的鍵
            // entry.getValue() 返回與此項對應的值
            System.out.print(entry.getValue());
            }
            System.out.println();
            System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
            }
            }
            對于keySet其實是遍歷了2次,一次是轉為iterator,一次就從hashmap中取出key所對于的value。而entryset只是遍歷了第一次,他把key和value都放到了entry中,所以就快了。


          Java中HashMap遍歷的兩種方式(本教程僅供研究和學習,不代表JAVA中文網觀點)
          本篇文章鏈接地址:http://www.javaweb.cc/language/java/032291.shtml
          如需轉載請注明出自JAVA中文網:http://www.javaweb.cc/


          還是第一種好,簡單。。。

          posted @ 2013-06-17 21:59 一堣而安 閱讀(216) | 評論 (0)編輯 收藏

          Myeclipse安裝findbugs(轉)

           http://hnwsha.blog.sohu.com/211993316.html
          分類: Java 2012-04-17
          13:13

          安裝方法如下:
          1、首先從findbugs網站下載插件:http://findbugs.sourceforge.net/downloads.html

          2、將下載回來的zip包解壓,得到文件夾:edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821,將該文件夾拷貝到myeclipse安裝目錄下common/plugins目錄下。我的目錄結構:D:\Genuitec\MyEclipse8.5\Common\plugins\edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821

          3、修改myeclipse安裝目錄下configuration/org.eclipse.equinox.simpleconfigurator的bundles.info文件,在文件最后添加一行:

          edu.umd.cs.findbugs.plugin.eclipse,1.3.9.20090821,file:/D:/Genuitec/MyEclipse8.5/Common/plugins/edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821,4,false
          注意最后一行不能有空格,回車之類的符號。

          這里file后面的路徑要根據自己的目錄設置進行修改,要不然重啟myeclipse后,仍然找不到findbugs。

          4、重啟myeclipse,選中項目,右鍵會出現一個Find
          Bugs菜單。至此,findbugs插件安裝完畢

          posted @ 2013-06-17 15:15 一堣而安 閱讀(3120) | 評論 (0)編輯 收藏

          js網頁滾動條滾動事件


          http://www.cnblogs.com/yongtaiyu/archive/2012/11/14/2769707.html
          js網頁滾動條滾動事件

          在做js返回頂部的效果時,要監(jiān)聽網頁滾動條滾動事件,這個事件就是:window.onscroll。當onscroll事件發(fā)生時,用js獲得頁面的scrollTop值,判斷scrollTop為一個設定值時,顯示“返回面部”
          js網頁滾動條滾動事件

          <style type="text/css">
          #top_div{
              position:fixed;
              bottom:80px;
              right:0;
              display:none;
          }
          </style>
          <script type="text/javascript">
          window.onscroll = function(){
              var t = document.documentElement.scrollTop || document.body.scrollTop; 
              var top_div = document.getElementById( "top_div" );
              if( t >= 300 ) {
                  top_div.style.display = "inline";
              } else {
                  top_div.style.display = "none";
              }
          }

          </script>
          <a name="top">頂部<a>
          <div id="top_div"><a href="#top">返回頂部</a></div>
          <br />
          <br />
          <div>
          這里盡量多些<br />以便頁面出現滾動條,限于篇幅本文此處略去
          </div>

          例子語法解釋
          在 style 標簽中首先定義 top_div css 屬性:position:fixed;display:none; 是關鍵
          javascript 語句中,t 得到滾動條向下滾動的位置,|| 是為了更好兼容性考慮
          當滾動超過 300 (像素)時,將 top_div css display 屬性設置為顯示(inline),反之則隱藏(none)
          必須設定 DOCTYPE 類型,在 IE 中才能利用 document.documentElement 來取得窗口的寬度及高度

          轉自:http://www.altmi.com/zg/index.php/archives/67/

          posted @ 2013-06-03 16:35 一堣而安 閱讀(526) | 評論 (0)編輯 收藏

          iframe 刷新

          JS實現刷新iframe的方法



          <iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe>


          方案一:用iframe的name屬性定位


          <input type="button" name="Button"
          value="Button"
          onclick="document.frames('ifrmname').location.reload()">


            或


          <input type="button" name="Button"
          value="Button"
          onclick="document.all.ifrmname.document.location.reload()">


            方案二:用iframe的id屬性定位


          <input type="button" name="Button"
          value="Button"
          onclick="ifrmid.window.location.reload()">


            終極方案:當iframe的src為其它網站地址(跨域操作時)


          <input type="button" name="Button"
          value="Button"
          onclick="window.open(document.all.ifrmname.src,'ifrmname','')">





          代碼如下:<input type=button value=刷新 onclick="history.go(0)">


          代碼如下:<input type=button value=刷新 onclick="location.reload()">


          代碼如下:<input type=button value=刷新 onclick="location=location">


          代碼如下:<input type=button value=刷新
          onclick="window.navigate(location)">


          代碼如下:<input type=button value=刷新 onclick="location.replace(location)">


          下面這三種我就不知道該怎么用了,就把代碼放在下面吧,哪位要是會的話,可教教大家。


          <input type=button value=刷新
          onclick="document.execCommand(@#Refresh@#)">


          <input type=button value=刷新
          onclick="window.open(@#自身的文件@#,@#_self@#)">


          <input type=button value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)>






          父頁面中存在兩個iframe,一個iframe中是一個鏈接列表,其中的鏈接指向另一個iframe,用于顯示內容?,F在當內容內容添加后,在鏈接列表中添加了一條記錄,則需要刷新列表iframe。


          在內容iframe的提交js中使用parent.location.reload()將父頁面全部刷新,因為另一個iframe沒有默認的url,只能通過列表選擇,所以只顯示了列表iframe的內容。


          使用window.parent.frames["列表iframe名字"].location="列表url"即可進刷新列表iframe,而內容iframe在提交后自己的刷新將不受影響。








          document.frames("refreshAlarm").location.reload(true); //ok


          document.frames("refreshAlarm").document.location.reload(true); //ok


          document.frames("refreshAlarm").document.location="/public/alarmsum.asp";//ok


          document.getElementByIdx_x("refreshAlarm").src="/public/alarmsum.asp"
          mce_src="/public/alarmsum.asp"; //ok


          document.frames("refreshAlarm").src="/public/alarmsum.asp"
          mce_src="/public/alarmsum.asp"; //沒變化,沒動靜


          注意區(qū)別,document.all.refreshAlarm 或 document.frames("refreshAlarm")
          得到的是information.asp頁面中那個iframe標簽,所以對src屬性操作有用。
          document.frames("refreshAlarm").document得到iframe里面的內容,也就是"/public/alarmsum.asp"中的內容。


          這里需要補充說明的是:


          采用document.getElementByIdx_x獲取后reload是不可以的


          但是可以這樣


          var myiframe = document.getElementByIdx_x("iframe1");


          myiframe.src = myiframe.src; //這樣同樣可以起到刷新的效果。



          自動刷新頁面



          javascript(js)自動刷新頁面的實現方法總結2008-04-18 13:24
          自動刷新頁面的實現方法總結:


          1)
          <meta
          http-equiv="refresh"content="10;url=跳轉的頁面">
          10表示間隔10秒刷新一次
          2)
          <script
          language=''javascript''>
          window.location.reload(true);
          </script>
          如果是你要刷新某一個iframe就把window給換成frame的名字或ID號
          3)
          <script
          language=''javascript''>
          window.navigate("本頁面url");
          </script>
          4>


          function
          abc()
          {
          window.location.href="/blog/window.location.href";
          setTimeout("abc()",10000);
          }


          刷新本頁:
          Response.Write("<script
          language=javascript>window.location.href=window.location.href;</script>")


          刷新父頁:
          Response.Write("<script
          language=javascript>opener.location.href=opener.location.href;</script>")


          轉到指定頁:
          Response.Write("<script
          language=javascript>window.location.href='yourpage.aspx';</script>")



          刷新頁面實現方式總結(HTML,ASP,JS)
          'by aloxy


          定時刷新:
          1,<script>setTimeout("location.href='url'",2000)</script>


          說明:url是要刷新的頁面URL地址
          2000是等待時間=2秒,


          2,<meta name="Refresh" content="n;url">


          說明:
          n is the number of seconds to wait before loading the specified
          URL.
          url is an absolute URL to be
          loaded.
          n,是等待的時間,以秒為單位
          url是要刷新的頁面URL地址


          3,<%response.redirect url%>


          說明:一般用一個url參數或者表單傳值判斷是否發(fā)生某個操作,然后利用response.redirect 刷新。


          4,刷新框架頁
             〈script
          language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload();</script〉


          彈出窗體后再刷新的問題



          Response.Write("<script>window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight:
          300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft:
          133px')</script>");//open
                      
          Response.Write("<script>document.location=document.location;</script>");


          在子窗體頁面代碼head中加入<base target="_self"/>


          刷新的內容加在    if (!IsPostBack) 中


          在框架頁中右面刷新左面
              //刷新框架頁左半部分
              Response.Write("<script
          language=javascript>");
             
          Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'");
             
          Response.Write("</script>");



          頁面定時刷新功能實現


          有三種方法:
          1,在html中設置:
          <title>xxxxx</title>之後加入下面這一行即可!
          定時刷新:<META
          HTTP-EQUIV="Refresh" content="10">
          10代表刷新間隔,單位為秒


          2.jsp
          <% response.setHeader("refresh","1"); %>
          每一秒刷新一次


          3.使用javascript:
          <script
          language="javascript">
          setTimeout("self.location.reload();",1000);
          <script>
          一秒一次



          頁面自動跳轉:
          1,在html中設置:
          <title>xxxxx</title>之後加入下面這一行即可!
          定時跳轉并刷新:<meta
          http-equiv="refresh"
          content="20;url=http://自己的URL">,
          其中20指隔20秒后跳轉到http://自己的URL 頁面。



          點擊按鈕提交表單后刷新上級窗口


          A窗口打開B窗口


          然后在B里面提交數據至C窗口


          最后要刷新A窗口


          并且關閉B窗口


          幾個javascript函數


          //第一個自動關閉窗口
          <script language="javascript">
          <!--
          function
          clock(){i=i-1
          document.title="本窗口將在"+i+"秒后自動關閉!";
          if(i>0)setTimeout("clock();",1000);
          else
          self.close();}
          var i=2
          clock();
          //-->
          </script>


          //第二個刷新父頁面的函數


          <script
          language="javascript">
          opener.location.reload();
          </script>



          //第三個打開窗口


          <script language="javascript">
          function
          show(mylink,mytitle,width,height)
          {mailwin=window.open(mylink,mytitle,'top=350,left=460,width='+width+',height='+height+',scrollbars=no')}
          </script>

          posted @ 2013-06-02 21:39 一堣而安 閱讀(646) | 評論 (0)編輯 收藏

          java正則表達式 提取、替換(轉)

               摘要: java正則表達式 提取、替換事例1http://www.cnblogs.com/lihuiyy/archive/2012/10/08/2715138.html比如,現在有一個 endlist.txt 文本文件,內容如下:1300102,北京市1300103,北京市1300104,北京市1300105,北京市1300106,北京市1300107,北京市1300108,北京市1300109,北京市1...  閱讀全文

          posted @ 2013-05-31 20:26 一堣而安 閱讀(3026) | 評論 (0)編輯 收藏

          oracle的nvl和sql server的isnull (轉)

          http://www.cnblogs.com/sunyjie/archive/2012/03/26/2417688.html

          最近公司在做Oracle數據庫相關產品,在這里作以小結:

          ISNULL()函數

          語法   
          ISNULL ( check_expression , replacement_value)   
          參數
             check_expression   
             將被檢查是否為    NULL的表達式。check_expression    可以是任何類型的。   
             replacement_value   
             在    check_expression    為    NULL時將返回的表達式。replacement_value    必須與    check_expresssion    具有相同的類型。     
          返回類型
             返回與    check_expression    相同的類型。   
          注釋
             如果    check_expression    不為    NULL,那么返回該表達式的值;否則返回    replacement_value。

          ----------------------------------------------------------------------------------------------

          ----------------------------------------------------------------------------------------------

          nvl( ) 函數

          從兩個表達式返回一個非 null 值。  
          語法
          NVL(eExpression1, eExpression2)   
          參數
          eExpression1, eExpression2   
          如果 eExpression1 的計算結果為 null 值,則 NVL( ) 返回 eExpression2。如果 eExpression1 的計算結果不是 null 值,則返回 eExpression1。eExpression1 和 eExpression2 可以是任意一種數據類型。如果 eExpression1 與 eExpression2 的結果皆為 null 值,則 NVL( ) 返回 .NULL.。   
          返回值類型
          字符型、日期型、日期時間型、數值型、貨幣型、邏輯型或 null 值   
          說明
          在不支持 null 值或 null 值無關緊要的情況下,可以使用 NVL( ) 來移去計算或操作中的 null 值。

          select nvl(a.name,'空得') as name from student a join school b on a.ID=b.ID

          注意:兩個參數得類型要匹配

          posted @ 2013-05-20 20:47 一堣而安 閱讀(286) | 評論 (0)編輯 收藏

          介紹概要設計和詳細設計該寫成什么程度(轉)

          http://wenku.baidu.com/view/78ed49eae009581b6bd9ebae.html

          posted @ 2013-05-07 17:18 一堣而安 閱讀(241) | 評論 (0)編輯 收藏

          僅列出標題
          共17頁: First 上一頁 6 7 8 9 10 11 12 13 14 下一頁 Last 

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          收藏夾

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 襄垣县| 靖安县| 浦北县| 韶关市| 盐山县| 永兴县| 元阳县| 昌宁县| 五河县| 西平县| 遵化市| 郁南县| 金湖县| 四子王旗| 页游| 汽车| 井陉县| 刚察县| 密山市| 林州市| 衡山县| 威海市| 滁州市| 灵石县| 仲巴县| 西林县| 静安区| 杂多县| 青州市| 泽州县| 岑溪市| 融水| 且末县| 徐州市| 会东县| 家居| 中西区| 三明市| 眉山市| 册亨县| 玉树县|