posts - 89, comments - 241, trackbacks - 0, articles - 1
             :: 首頁 ::  :: 聯(lián)系 :: 聚合  :: 管理

          2009年12月18日

               摘要: 代碼改編自 NetPuter 大大發(fā)布的 SDK,這份 SDK 是我用過的最好的 PHP SDK,修改了一些東西:1、增加了收到的訊息類型 voice video2、收到text的時(shí)候,如果是 hello2bizuser 的話,調(diào)用 onsubscribe 方法(微信4.x 以前貌似都還是發(fā)hello2bizuser 所以不得不兼容啊)Code highlighting produced by A...  閱讀全文

          posted @ 2013-08-24 16:02 saobaolu| 編輯 收藏

          <TABLE style="table-layout: auto | fixed">
          auto: 默認(rèn)值
          fixed: 寬度固定,截?cái)喑龅膬?nèi)容

          <TABLE style="word-break: normal | break-all | keep-all">
          normal: 默認(rèn)值,按字詞截?cái)鄵Q行
          break-all: 強(qiáng)行截?cái)嗖Q行
          keep-all: 不截?cái)嗖粨Q行

          使用:style="table-layout:fixed;"
          表示輸出停止,停留在設(shè)定的長度內(nèi).

          使用:style="word-break : break-all;"
          表示對(duì)超長部分,換行再繼續(xù)顯示.

          對(duì)于在英文中使用,請(qǐng)使用style="table-layout:fixed; word-wrap:break-word"
          推薦使用word-wrap:break-word;word-break:break-all;table-layout:fixed;

          ==============================================================================

          word-wrap同word-break的區(qū)別

          word-wrap:
          normal      Default. Content exceeds the boundaries of its container. 
          break-word Content wraps to next line, and a word-break occurs when necessary. 必要時(shí)會(huì)觸發(fā)word-break。

          word-break:
          normal      Default. Allows line breaking within words. 好像是只對(duì)Asian text起作用。
          break-all Behaves the same as normal for Asian text, yet allows the line to break arbitrarily for non-Asian text. This value is suited to Asian text that contains some excerpts of non-Asian text. 
          keep-all Does not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean.

          總結(jié)如下:
          word-wrap是控制換行的。
          使用break-word時(shí),是將強(qiáng)制換行。中文沒有任何問題,英文語句也沒問題。但是對(duì)于長串的英文,就不起作用。

          break-word是控制是否斷詞的。
          normal是默認(rèn)情況,英文單詞不被拆開。
          break-all,是斷開單詞。在單詞到邊界時(shí),下個(gè)字母自動(dòng)到下一行。主要解決了長串英文的問題。
          keep-all,是指Chinese, Japanese, and Korean不斷詞。即只用此時(shí),不用word-wrap,中文就不會(huì)換行了。(英文語句正常。)


          ie下:
          使用word-wrap:break-word;所有的都正常。

          ff下:
          如這2個(gè)都不用的話,中文不會(huì)出任何問題。英文語句也不會(huì)出問題。但是,長串英文會(huì)出問題。
          為了解決長串英文,一般用word-wrap:break-word;word-break:break-all;。但是,此方式會(huì)導(dǎo)致,普通的英文語句中的單詞會(huì)被斷開(ie下也是)。

          目前主要的問題存在于 長串英文 和 英文單詞被斷開。其實(shí)長串英文就是一個(gè)比較長的單詞而已。
          即英文單詞應(yīng)不應(yīng)該被斷開那?那問題很明顯了,顯然不應(yīng)該被斷開了。
          對(duì)于長串英文,就是惡意的東西,自然不用去管了。但是,也要想些辦法,不讓它把容器撐大。
          用:overflow:auto; ie下,長串會(huì)自動(dòng)折行。ff下,長串會(huì)被遮蓋。


          所以,綜上,最好的方式是word-wrap:break-word;overflow:hidden;而不是word-wrap:break-word;word-break:break-all;。
          word-wrap:break-word;overflow:auto;在ie下沒有任何問題。在ff下,長串會(huì)被遮住部分內(nèi)容。

          另,測試代碼如下:

          1.htm===================================================================

          <style>
          .c1{ width:300px;      border:1px solid red}
          .c2{ width:300px;word-wrap:break-word;      border:1px solid yellow}
          .c3{ width:300px;word-wrap:break-word;word-break:break-all;      border:1px solid green}
          .c4{ width:300px;word-wrap:break-word;word-break:keep-all; border:1px solid blue}
          .c5{ width:300px;word-break:break-all;      border:1px solid black}
          .c6{ width:300px;word-break:keep-all;      border:1px solid red}
          .c7{ width:300px;word-wrap:break-word;overflow:auto;      border:1px solid yellow}
          </style>

          .c1{ width:300px;      border:1px solid red}
          <div class="c1">
          safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
          </div>
          <div class=c1>
          This is all English. This is all English. This is all English.
          </div>
          <div class=c1>
          全是中文的情況。全是中文的情況。全是中文的情況。
          </div>
          <div class=c1>
          中英文混排的情況。Chinese and English. 中英文混排的情況。Chinese and English. 
          </div>

          <br>
          .c2{ width:300px;word-wrap:break-word; border:1px solid yellow}
          <div class="c2">
          safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
          </div>
          <div class=c2>
          This is all English. This is all English. This is all English.
          </div>
          <div class=c2>
          全是中文的情況。全是中文的情況。全是中文的情況。
          </div>
          <div class=c2>
          中英文混排的情況。Chinese and English. 中英文混排的情況。Chinese and English. 
          </div>

          <br>
          .c3{ width:300px;word-wrap:break-word;word-break:break-all;      border:1px solid green}
          <div class="c3">
          safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
          </div>
          <div class=c3>
          This is all English. This is all English. This is all English.
          </div>
          <div class=c3>
          全是中文的情況。全是中文的情況。全是中文的情況。
          </div>
          <div class=c3>
          中英文混排的情況。Chinese and English. 中英文混排的情況。Chinese and English. 
          </div>

          <br>
          .c4{ width:300px;word-wrap:break-word;word-break:keep-all; border:1px solid blue}
          <div class="c4">
          safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
          </div>
          <div class=c4>
          This is all English. This is all English. This is all English.
          </div>
          <div class=c4>
          全是中文的情況。全是中文的情況。全是中文的情況。
          </div>
          <div class=c4>
          中英文混排的情況。Chinese and English. 中英文混排的情況。Chinese and English. 
          </div>

          <br>
          .c5{ width:300px;word-break:break-all;      border:1px solid black}
          <div class="c5">
          safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
          </div>
          <div class=c5>
          This is all English. This is all English. This is all English.
          </div>
          <div class=c5>
          全是中文的情況。全是中文的情況。全是中文的情況。
          </div>
          <div class=c5>
          中英文混排的情況。Chinese and English. 中英文混排的情況。Chinese and English. 
          </div>

          <br>
          .c6{ width:300px;word-break:keep-all;      border:1px solid red}
          <div class="c6">
          safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
          </div>
          <div class=c6>
          This is all English. This is all English. This is all English.
          </div>
          <div class=c6>
          全是中文的情況。全是中文的情況。全是中文的情況。
          </div>
          <div class=c6>
          中英文混排的情況。Chinese and English. 中英文混排的情況。Chinese and English. 
          </div>

          <br>
          .c7{ width:300px;word-wrap:break-word;overflow:auto;      border:1px solid yellow}
          <div class="c7">
          safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
          </div>
          <div class=c7>
          This is all English. This is all English. This is all English.
          </div>
          <div class=c7>
          全是中文的情況。全是中文的情況。全是中文的情況。
          </div>
          <div class=c7>
          中英文混排的情況。Chinese and English. 中英文混排的情況。Chinese and English. 
          </div>

          posted @ 2010-07-06 22:43 saobaolu| 編輯 收藏

           1 import java.io.*;
           2 import java.util.Scanner;
           3 public class SortTest {
           4     public static void main(String[] args) throws IOException {
           5         int temp = 0;//臨時(shí)變量,用于冒泡交換        
           6         int[] num=new int[10];  //聲明一個(gè)空的數(shù)組  10個(gè)長度
           7         Scanner sc = new Scanner(System.in);
           8         FileOutputStream out=new FileOutputStream("1.txt");
           9         PrintStream p=new PrintStream(out);
          10         //開始循環(huán)賦值
          11         for(int i =0;i<num.length;i++){
          12             num[i]=sc.nextInt();
          13         }
          14         p.append("排序前為:");
          15         for (int i = 0; i <num.length; i++) {
          16             System.out.println(num[i]);
          17             p.append(num[i]+" , ");
          18         }
          19         // 用于排序
          20         for (int i = 0; i < num.length-1; i++) {
          21             for (int j = 0; j < num.length - i - 1; j++) {
          22                 if (num[j] > num[j + 1]) {
          23                     temp = num[j];
          24                     num[j] = num[j + 1];
          25                     num[j + 1= temp;
          26                 }
          27             }
          28         }
          29         //輸出文件
          30         p.append("\n");
          31         p.append("排序后為:");
          32         // 循環(huán)輸出
          33         System.out.println("排序后為:");
          34         for (int i = 0; i <num.length; i++) {
          35             System.out.println(num[i]);
          36             p.append(num[i]+" , ");
          37         }
          38     
          39         
          40     }
          41 }
          最后應(yīng)該把p給close了哈

          posted @ 2010-06-26 09:02 saobaolu| 編輯 收藏

          轉(zhuǎn)自:http://www.ry168.net/bbs/thread-226-1-1.html
          table不能換行問題 一般是:一行里面全是數(shù)字或是字母或者結(jié)尾有多個(gè)感嘆號(hào)而導(dǎo)致 table不能換行,中文默認(rèn)的會(huì)自動(dòng)換行的,字母不能換行問題:
          style="table-layout:fixed; word-break: break-all; overflow:hidden;"
          復(fù)制代碼在單元格屬性里加入上面這句,如:
          <td style="table-layout:fixed; word-break: break-all; overflow:hidden;">
          復(fù)制代碼用表格做網(wǎng)頁排版的時(shí)候,一般都能正常使用。偏偏有時(shí)會(huì)碰到一段連續(xù)的英文詞或者一堆感嘆號(hào)(!!!)把網(wǎng)頁就撐開的現(xiàn)象。

          總結(jié)了一下,只要在CSS中定義了如下句子,可保網(wǎng)頁不會(huì)再被撐開了。

          自動(dòng)換行問題,正常字符的換行是比較合理的,而連續(xù)的數(shù)字和英文字符常常將容器撐大,挺讓人頭疼,下面介紹的是CSS如何實(shí)現(xiàn)換行的方法

          對(duì)于div,p等塊級(jí)元素

          正常文字的換行(亞洲文字和非亞洲文字)元素?fù)碛心J(rèn)的white-space:normal,當(dāng)定義的寬度之后自動(dòng)換行

          html
          <div id="wrap">正常文字的換行(亞洲文字和非亞洲文字)元素?fù)碛心J(rèn)的white-space:normal,當(dāng)定義</div>
          css
          #wrap{white-space:normal; width:200px; }

          IE瀏覽器

          連續(xù)的英文字符和阿拉伯?dāng)?shù)字,使用word-wrap: break-word ;或者word-break:break-all;實(shí)現(xiàn)強(qiáng)制斷行

          html
          <div id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>

          css
          #wrap{word-break:break-all; width:200px;}
          或者
          #wrap{word-wrap:break-word; width:200px;}

          Firefox瀏覽器
          連續(xù)的英文字符和阿拉伯?dāng)?shù)字的斷行,Firefox的所有版本的沒有解決這個(gè)問題,我們只有讓超出邊界的字符隱藏或者,給容器添加滾動(dòng)條

          html
          <div id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>

          css
          #wrap{word-break:break-all; width:200px; overflow:auto;}

          對(duì)于table元素
          IE瀏覽器
          1. 使用 table-layout:fixed;強(qiáng)制table的寬度,多余內(nèi)容隱藏<table style="table-layout:fixed" width="200"><tr><td>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td></tr></table>
          復(fù)制代碼2. 使用 table-layout:fixed;強(qiáng)制table的寬度,內(nèi)層td,th采用word-break : break-all;或者word-wrap : break-word ;換行 <table width="200" style="table-layout:fixed;"><tr><td width="25%" style="word-break : break-all; ">abcdefghigklmnopqrstuvwxyz 1234567890</td><td style="word-wrap : break-word ;">abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>
          復(fù)制代碼3.在td,th中嵌套div,p等采用上面提到的div,p的換行方法

          Firefox瀏覽器

          1. 使用 table-layout:fixed;強(qiáng)制table的寬度,內(nèi)層td,th采用word-break : break-all;或者word-wrap : break-word ;換行,使用overflow:hidden;隱藏超出內(nèi),這里overflow:auto;無法起作用<table style="table-layout:fixed" width="200"><tr>

          <td width="25%"  style="word-break : break-all; overflow:hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>

          <td width="75%" style="word-wrap : break-word; overflow:hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>

          </tr></table>
          復(fù)制代碼2.在td,th中嵌套div,p等采用上面提到的對(duì)付Firefox的方法。

          最佳CSS定義換行代碼.wrap { table-layout:fixed; word-break: break-all; overflow:hidden; }
          復(fù)制代碼當(dāng)然,這種現(xiàn)象出現(xiàn)的幾率很小,但是不能排除網(wǎng)友的惡搞。

          posted @ 2010-06-25 14:06 saobaolu| 編輯 收藏

          網(wǎng)址是http://wp.qq.com
          發(fā)現(xiàn)這個(gè)玩意越來越強(qiáng)大了,就忍不住把官方的介紹搬過來:
          代碼樣例
          <a href="http://sighttp.qq.com/cgi-bin/check?sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d";target=_blank; onclick="var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" SRC='http://wpa.qq.com/pa?p=1:80000805:1' alt="點(diǎn)擊這里給我發(fā)消息"></a>

          1)、sigkey為個(gè)人鑒權(quán)key,請(qǐng)勿修改,否則無法發(fā)起臨時(shí)會(huì)話。

          2)、臨時(shí)會(huì)話圖標(biāo)<img border="0" SRC='http://wpa.qq.com/pa?p=1:80000805:1' alt="點(diǎn)擊這里給我發(fā)消息">

          SRC是圖標(biāo)鏈接,自定義圖標(biāo)中可以替換這一部分為自己圖片的鏈接,

          參數(shù):

          P=以冒號(hào)“:”分隔多個(gè)參數(shù)

          第一個(gè)參數(shù)為版本號(hào),目前為1;

          第二個(gè)為QQ/TM號(hào)碼;

          第三個(gè)參數(shù)為圖像風(fēng)格,支持多種狀態(tài)。

          alt是圖標(biāo)旁留言。

          3)、除了自定義圖標(biāo)需要修改臨時(shí)會(huì)話圖標(biāo)外,其他情況下建議不要修改代碼,因?yàn)橛锌赡軐?dǎo)致在不同的環(huán)境和瀏覽器下,無法發(fā)起臨時(shí)會(huì)話。


          自定義在線風(fēng)格圖片

          用JS實(shí)現(xiàn),具體步驟如下:

          1) 申請(qǐng)代碼

          <a href="http://sighttp.qq.com/cgi-bin/check?sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d"; target=_blank; onclick="var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" SRC='http://wpa.qq.com/pa?p=1:80000805:1' alt="點(diǎn)擊這里給我發(fā)消息"></a>

          2) 定義online數(shù)組,必須是online命名

          <script>var online= new Array();</script>

          3) 獲取在線狀態(tài)

          <script src="http://webpresence.qq.com/getonline?Type=1&80000805:"></script>

          可以獲取多個(gè),必須以冒號(hào)分隔,以冒號(hào)結(jié)尾,比如:

          <script src="http://webpresence.qq.com/getonline?Type=1&80000805:10000:123456:"></script>

          online[0]=0,表示80000805離線

          online[1]=1,表示10000在線

          online[2]=1,表示123456在線

          填寫號(hào)碼的先后順序,分別對(duì)應(yīng)數(shù)組online的0、1、2

          4) 添加代碼

          把SRC='http://wpa.qq.com/pa?p=1:80000805:1'替換為自己的圖片,比如:

          <script> if(online[0]==0) document.write("<a href="http://sighttp.qq.com/cgi-bin/check?sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d"; target=_blank; onclick="var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" SRC='http://xxxx/outline.jpg' alt="點(diǎn)擊這里給我發(fā)消息"></a>"); 
          else document.write("<a href="http://sighttp.qq.com/cgi-bin/check?sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d"; target=_blank; onclick="var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=81a37f0b7cac68639bddfdb9b93a6c92bc211f3e3a4e683afbb31a079382dc9d';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" SRC='http://xxxx/online.jpg' alt="點(diǎn)擊這里給我發(fā)消息"></a>"); </script> 

          我是這樣看的,用tx的方法得到某QQ號(hào)是否在線,用js判斷,顯示online.jpg或者outline.jpg這兩個(gè)圖片,其余不變。

          posted @ 2010-06-25 07:28 saobaolu| 編輯 收藏

           

          package myeclipsegen;

          import java.io.*;

          public class MyEclipseGen {
              
          private static final String LL = "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.";
              
          public String getSerial(String userId, String licenseNum) {
                  java.util.Calendar cal 
          = java.util.Calendar.getInstance();
                  cal.add(
          13);
                  cal.add(
          6-1);
                  java.text.NumberFormat nf 
          = new java.text.DecimalFormat("000");
                  licenseNum 
          = nf.format(Integer.valueOf(licenseNum));
                  String verTime 
          = new StringBuilder("-").append(new java.text.
                          SimpleDateFormat(
          "yyMMdd").format(cal.getTime())).append("0").
                                   toString();
                  String type 
          = "YE3MP-";
                  String need 
          = new StringBuilder(userId.substring(01)).append(type).
                                append(
          "300").append(licenseNum).append(verTime).toString();
                  String dx 
          = new StringBuilder(need).append(LL).append(userId).toString();
                  
          int suf = this.decode(dx);
                  String code 
          = new StringBuilder(need).append(String.valueOf(suf)).
                                toString();
                  
          return this.change(code);
              }

              
          private int decode(String s) {
                  
          int i;
                  
          char[] ac;
                  
          int j;
                  
          int k;
                  i 
          = 0;
                  ac 
          = s.toCharArray();
                  j 
          = 0;
                  k 
          = ac.length;
                  
          while (j < k) {
                      i 
          = (31 * i) + ac[j];
                      j
          ++;
                  }
                  
          return Math.abs(i);
              }

              
          private String change(String s) {
                  
          byte[] abyte0;
                  
          char[] ac;
                  
          int i;
                  
          int k;
                  
          int j;
                  abyte0 
          = s.getBytes();
                  ac 
          = new char[s.length()];
                  i 
          = 0;
                  k 
          = abyte0.length;
                  
          while (i < k) {
                      j 
          = abyte0[i];
                      
          if ((j >= 48&& (j <= 57)) {
                          j 
          = (((j - 48+ 5% 10+ 48;
                      } 
          else if ((j >= 65&& (j <= 90)) {
                          j 
          = (((j - 65+ 13% 26+ 65;
                      } 
          else if ((j >= 97&& (j <= 122)) {
                          j 
          = (((j - 97+ 13% 26+ 97;
                      }
                      ac[i] 
          = (char) j;
                      i
          ++;
                  }
                  
          return String.valueOf(ac);
              }

              
          public MyEclipseGen() {
                  
          super();
              }

              
          public static void main(String[] args) {
                  
          try {
                      System.out.println(
          "please input register name:");
                      BufferedReader reader 
          = new BufferedReader(new InputStreamReader(
                              System.in));
                      String userId 
          = null;
                      userId 
          = reader.readLine();
                      MyEclipseGen myeclipsegen 
          = new MyEclipseGen();
                      String res 
          = myeclipsegen.getSerial(userId, "20");
                      System.out.println(
          "Serial:" + res);
                      reader.readLine();
                  } 
          catch (IOException ex) {
                  }
              }
          }
          點(diǎn)此下載源文件和編譯好的class文件吧
          /Files/chenglu/MyEclipse61Gen.zip
          額,還有,MyEclipse6的下載地址是:請(qǐng)使用迅雷下載。。http://downloads.myeclipseide.com/downloads/products/eworkbench/6.0.1GA/MyEclipse_6.0.1GA_E3.3.1_FullStackInstaller.exe

          posted @ 2010-06-19 22:09 saobaolu| 編輯 收藏

          先來看html代碼
          <p>
            
          <label>選擇分類</label>
              
          <select name="classId">
                
          <option value="1">企業(yè)動(dòng)態(tài)</option>
                
          <option value="2">最新活動(dòng)</option>
              
          </select>
          </p>
          在純struts2中獲取用戶選擇值直接
          private String classId;
           
          public void setTitle(String title) {
            
          this.title = title;
           }
           
          public String getClassId() {
            
          return classId;
           }
          就可以,需要注意的是select一定要帶name,option取到的是value

          posted @ 2010-06-17 07:12 saobaolu| 編輯 收藏

           

          import java.io.UnsupportedEncodingException;
          import java.security.MessageDigest;
          import java.security.NoSuchAlgorithmException;
          import sun.misc.BASE64Encoder;

              
          public String EncoderByMd5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException {
                  
          //確定計(jì)算方法
                  MessageDigest md5=MessageDigest.getInstance("MD5");
                  BASE64Encoder base64en 
          = new BASE64Encoder();
                  
          //加密后的字符串
                  String newstr=base64en.encode(md5.digest(str.getBytes("utf-8")));
                  
          return newstr;
              }
           u錯(cuò)了,這不是md5的算法,是md5+base64加密,,

          posted @ 2010-06-16 09:09 saobaolu| 編輯 收藏

          1
          2if(rs.isAfterLast()==rs.isBeforeFirst()){
          3    out.print("您所查找的信息不存在,請(qǐng)確認(rèn)后再查找!");
          4    }
          else{
          5
          6}

          posted @ 2010-03-22 21:24 saobaolu| 編輯 收藏

          posted @ 2010-01-26 11:17 saobaolu| 編輯 收藏

          r(Read,讀取):對(duì)文件而言,具有讀取文件內(nèi)容的權(quán)限;對(duì)目錄來說,具有瀏覽目錄的權(quán)限。
          w(Write,寫入):對(duì)文件而言,具有新增、修改文件內(nèi)容的權(quán)限;對(duì)目錄來說,具有刪除、移動(dòng)目錄內(nèi)文件的權(quán)限。
          x(eXecute,執(zhí)行):對(duì)文件而言,具有執(zhí)行文件的權(quán)限;對(duì)目錄了來說該用戶具有進(jìn)入目錄的權(quán)限。
          e.g.  -rw-r--r--
          1.去掉第一個(gè)- 后面三個(gè)三個(gè)為一組 rw-/r--/r--  (所有者權(quán)限/組用戶權(quán)限/其他用戶權(quán)限)
          2.解析:所有者權(quán)限:讀取、寫入、不可執(zhí)行;本組用戶權(quán)限:讀取、不可寫入、不可執(zhí)行;其他用戶權(quán)限:讀取、不可寫入、不可執(zhí)行。
          3.兩種方式去解析成數(shù)字表示法:
              3.1:r: 對(duì)應(yīng)數(shù)值4  w: 對(duì)應(yīng)數(shù)值2  x:對(duì)應(yīng)數(shù)值1,則:4+2+1=7/4+0+0=4/4+0+0=4:744權(quán)限
              3.2:將其轉(zhuǎn)換成二進(jìn)制數(shù),有值就是1,沒值就是0,則:110/100/100,轉(zhuǎn)換成十進(jìn)制:110=7/100=4/110=4:744權(quán)限

          posted @ 2010-01-08 04:36 saobaolu| 編輯 收藏

               摘要:   《Linux(第1—4章)總結(jié)》 1.       linux操作系統(tǒng)的特點(diǎn):開放性,多用戶,多任務(wù),良好的用戶界面,設(shè)備獨(dú)立性,出色的速度性能,豐富的網(wǎng)絡(luò)功能,可靠的安全性,可移植性強(qiáng),安全符合POSIX標(biāo)準(zhǔn),UNIX的完整實(shí)現(xiàn),開發(fā)功能強(qiáng)。 2.     &nbs...  閱讀全文

          posted @ 2010-01-08 02:45 saobaolu| 編輯 收藏

               摘要:   1.       基本的 HTML 標(biāo)簽 標(biāo)簽 描述 ...  閱讀全文

          posted @ 2010-01-07 16:31 saobaolu| 編輯 收藏

          Spring的applicationContext.xml文件

          想必用過Spring的程序員們都有這樣的感覺,Spring把邏輯層封裝的太完美了(個(gè)人感覺View層封裝的不是很好)。以至于有的初學(xué)者 都不知道Spring配置文件的意思,就拿來用了。所以今天我給大家詳細(xì)解釋一下Spring的applicationContext.xml文件。 Ok,我還是通過代碼加注釋的方式為大家演示: 以下是詳解Spring的applicationContext.xml文件代碼:
          <!-- 頭文件,主要注意一下編碼 -->
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
          <beans>
          <!-- 建立數(shù)據(jù)源 -->
           <bean >
          <!-- 數(shù)據(jù)庫驅(qū)動(dòng),我這里使用的是Mysql數(shù)據(jù)庫 -->
            <property >
             <value>com.mysql.jdbc.Driver</value>
            </property>
          <!-- 數(shù)據(jù)庫地址,這里也要注意一下編碼,不然亂碼可是很郁悶的哦! -->
            <property >
             <value>
                 jdbc:mysql://localhost:3306/tie?useUnicode=true&characterEncoding=utf-8
             </value>
            </property>
          <!-- 數(shù)據(jù)庫的用戶名 -->
            <property >
             <value>root</value>
            </property>
          <!-- 數(shù)據(jù)庫的密碼 -->
            <property >
             <value>123</value>
            </property>
           </bean>
          <!-- 把數(shù)據(jù)源注入給Session工廠 -->
           <bean
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property >
             <ref bean="dataSource" />
            </property>
          <!-- 配置映射文件 -->
            <property >
             <list>
              <value>com/alonely/vo/User.hbm.xml</value>
             </list>
            </property>
           </bean>
          <!-- 把Session工廠注入給hibernateTemplate -->
           <!-- 解釋一下hibernateTemplate:hibernateTemplate提供了很多方便的方法,在執(zhí)行時(shí)自動(dòng)建立 HibernateCallback 對(duì)象,例如:load()、get()、save、delete()等方法。 -->
           <bean
            class="org.springframework.orm.hibernate3.HibernateTemplate">
            <constructor-arg>
             <ref local="sessionFactory" />
            </constructor-arg>
           </bean>
          <!-- 把DAO注入給Session工廠 -->
           <bean >
            <property >
             <ref bean="sessionFactory" />
            </property>
           </bean>
          <!-- 把Service注入給DAO -->
           <bean >
            <property >
             <ref local="userDAO" />
            </property>
           </bean>
          <!-- 把Action注入給Service -->
           <bean >
            <property >
             <ref bean="userService" />
            </property>
           </bean>
          </beans>
          以上Spring的applicationContext.xml文件我是用的SSH架構(gòu),如果您用Spring的MVC架構(gòu),其原理也是一樣的。

          posted @ 2010-01-02 23:42 saobaolu| 編輯 收藏

          Linux下Squid代理服務(wù)器的配置(轉(zhuǎn))

          啟動(dòng)squid時(shí)如果不在squid.conf中設(shè)置主機(jī)名將無法啟動(dòng),必須要設(shè)置visible_hostname這個(gè)參數(shù)值,本文中,設(shè)置的主機(jī)名是服務(wù)器的真實(shí)機(jī)器名powersite,在squid.conf中找到該項(xiàng)并修改:
          visible_hostname linuxserver

          你想讓所有員工僅在上班時(shí)可上網(wǎng),而且不允許192.168.1.23這臺(tái)主機(jī)上網(wǎng),可以加入這樣的配置:
          # 將以下ACL添加到squid.conf的ACL配置部分
          acl home_network src 192.168.1.0/24
          acl business_hours time M T W H F 9:00-17:00
          acl RestrictedHost src 192.168.1.23
          # 將這些內(nèi)容添加到squid.conf的http_access配置部分
          http_access deny RestrictedHost
          http_access allow home_network business_hours

          你只想在早晨這段時(shí)間允許員工訪問Internet:
          # 將以下ACL添加到squid.conf的ACL配置部分
          acl mornings time 08:00-12:00
          # 將這些內(nèi)容添加到squid.conf的http_access配置部分
          http_access allow mornings

          Squid支持從外部讀取包含有web站點(diǎn)或域名的文件進(jìn)行ACL限制。在下面的例子中創(chuàng)建了兩個(gè)文件,/etc/squid/allowed-sites.squid和/etc/squid/restricted-sites.squid,很明顯,一個(gè)是允許訪問的站點(diǎn)文件,另一個(gè)是限制訪問站點(diǎn)文件。
          # vi /etc/squid/allowed-sites.squid
          www.163.com
          www.yahoo.cn

          # vi /etc/squid/restricted-sites.squid
          www.sex.com
          sex.com
          然后配置在工作時(shí)間允許或限制訪問的目標(biāo)站點(diǎn),以下的ACL配置和前面的略微不同:
          #
          # 將以下ACL添加到squid.conf的ACL配置部分
          #
          acl home_network src 192.168.1.0/24
          acl business_hours time M T W H F 9:00-17:00
          acl GoodSites dstdomain "/etc/squid/allowed-sites.squid"
          acl BadSites dstdomain "/etc/squid/restricted-sites.squid"

          #
          # 將這些內(nèi)容添加到squid.conf的http_access配置部分
          #
          http_access deny BadSites
          http_access allow home_network business_hours GoodSites

          根據(jù)IP地址限制Web訪問
          這個(gè)ACL訪問控制列表可以限制整個(gè)一個(gè)網(wǎng)段,功能還是很強(qiáng)的。
          #
          # 將以下ACL添加到squid.conf的ACL配置部分
          #
          acl home_network src 192.168.1.0/255.255.255.0
          然后添加http_access允許這個(gè)ACL:
          #
          # 將這些內(nèi)容添加到squid.conf的http_access配置部分
          #
          http_access allow home_network

          設(shè)置Squid為透明代理
          如果客戶端連接網(wǎng)絡(luò),就需要在瀏覽器設(shè)置Squid代理服務(wù)器,這是件比較麻煩的工作,而且代理服務(wù)器的地址或端口更換,每臺(tái)服務(wù)器都必須重新設(shè)置才能生效,想解決這個(gè)問題,可以使用透明代理的方法。透明代理就是使用iptables防火墻將squid的3128端口的請(qǐng)求全部轉(zhuǎn)發(fā)到HTTP的80端口,從而實(shí)現(xiàn)透明代理。
          2.6內(nèi)核版本之上:新版本的squid只需要修改成如下的內(nèi)容即可。默認(rèn)是“http_port 3128”,要將其改為“http_port 3128 transparent”的形式:
          另外還要配置iptables防火墻
          在下面兩個(gè)例子中,作為防火墻的服務(wù)器有兩塊網(wǎng)卡,連接Internet的eth0和連接內(nèi)網(wǎng)的eth1,同時(shí)防火墻也是內(nèi)網(wǎng)的網(wǎng)關(guān)。
          如果Squid服務(wù)器和防火墻在一臺(tái)服務(wù)器上,那么所有的HTTP80端口的請(qǐng)求將轉(zhuǎn)發(fā)到Squid服務(wù)的配置端口3128上。
          iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
          iptables -A INPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -i eth1 -p tcp --dport 3128
          iptables -A OUTPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -o eth0 -p tcp --dport 80
          iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -i eth0 -p tcp --sport 80
          iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -o eth1 -p tcp --sport 80
          如果Squid服務(wù)器和防火墻在不同的服務(wù)器上,iptables的規(guī)則將有所不同:
          iptables -t nat -A PREROUTING -i eth1 -s ! 192.168.1.100 -p tcp --dport 80 -j DNAT --to 192.168.1.100:3128
          iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.0/24 -d 192.168.1.100 -j SNAT --to 192.168.1.1
          iptables -A FORWARD -s 192.168.1.0/24 -d 192.168.1.100 -i eth1 -o eth1 -m state
          --state NEW,ESTABLISHED,RELATED -p tcp --dport 3128 -j ACCEPT
          iptables -A FORWARD -d 192.168.1.0/24 -s 192.168.1.100 -i eth1 -o eth1 -m state --state ESTABLISHED,RELATED -p tcp --sport 3128 -j ACCEPT

          Squid的密碼驗(yàn)證
          1) 創(chuàng)建密碼文件。密碼和用戶名存放在/etc/squid/squid_passwd文件中,并需要將這個(gè)文件的權(quán)限設(shè)置為其它用戶只讀。
          # touch /etc/squid/squid_passwd
          # chmod o+r /etc/squid/squid_passwd
          (2)使用htpasswd添加用戶,并設(shè)置密碼。添加用戶不需要對(duì)squid進(jìn)行重啟操作,我創(chuàng)建的用戶名是www
          # htpasswd /etc/squid/squid_passwd www
          New password:
          Re-type password for user www
          #
          (3)找到ncsa_auth命令的具體位置,后面的配置需要用到絕對(duì)路徑
          # which ncsa_auth
          /usr/sbin/ncsa_auth
          (4) 然后我們就要在squid.conf文件中定義驗(yàn)證程序了,創(chuàng)建名為ncsa_users的ACL并加入關(guān)鍵字REQUIRED來強(qiáng)制讓Squid使用NCSA驗(yàn)證方法。
          #
          # 在squid.conf的auth_param部分添加下列內(nèi)容
          #
          auth_param basic program /usr/sbin/ncsa_auth /etc/squid/squid_passwd

          #
          # 將以下ACL添加到squid.conf的ACL配置部分
          #
          acl ncsa_users proxy_auth REQUIRED

          #
          # 將這些內(nèi)容添加到squid.conf的http_access配置部分
          #
          http_access allow ncsa_users

          posted @ 2009-12-18 08:24 saobaolu| 編輯 收藏

          主站蜘蛛池模板: 元谋县| 平江县| 崇信县| 揭西县| 洛阳市| 托克托县| 彭泽县| 永清县| 丰镇市| 凌源市| 韶山市| 斗六市| 两当县| 徐州市| 丰镇市| 米泉市| 濉溪县| 多伦县| 莆田市| 濮阳县| 郎溪县| 平阳县| 新营市| 铜鼓县| 黎城县| 石泉县| 连云港市| 西吉县| 通山县| 杭锦旗| 遂平县| 巴林左旗| 烟台市| 汉中市| 唐山市| 临泉县| 宾川县| 什邡市| 隆昌县| 达州市| 兴山县|