国产精品精华液网站,久久久久五月天,亚洲香蕉伊在人在线观http://www.aygfsteel.com/unilobster/category/41363.html有個標題zh-cnTue, 06 Sep 2011 16:58:25 GMTTue, 06 Sep 2011 16:58:25 GMT60oracle合并查詢http://www.aygfsteel.com/unilobster/articles/357818.html游雯游雯Fri, 02 Sep 2011 06:29:00 GMThttp://www.aygfsteel.com/unilobster/articles/357818.htmlhttp://www.aygfsteel.com/unilobster/comments/357818.htmlhttp://www.aygfsteel.com/unilobster/articles/357818.html#Feedback0http://www.aygfsteel.com/unilobster/comments/commentRss/357818.htmlhttp://www.aygfsteel.com/unilobster/services/trackbacks/357818.html
例如:
    opt    seq
1.  a      11
2.  a      12
3.  a      13
4.  b      11
5.  b      12
查詢結果是
    opt    seq
1.  a      11,12,13
2.  b      11,12

解決辦法:
針對oracle 10以上可以用wmsys.wm_concat函數。
1 SELECT opt, wmsys.wm_concat(seq) 
2    FROM t_test_Table 
3    GROUP BY opt;

針對mysql,類似可以使用
group_concat函數。





游雯 2011-09-02 14:29 發表評論
]]>
多選框左右移 select multiple="multiple" 超時loophttp://www.aygfsteel.com/unilobster/articles/340044.html游雯游雯Wed, 08 Dec 2010 03:07:00 GMThttp://www.aygfsteel.com/unilobster/articles/340044.htmlhttp://www.aygfsteel.com/unilobster/comments/340044.htmlhttp://www.aygfsteel.com/unilobster/articles/340044.html#Feedback0http://www.aygfsteel.com/unilobster/comments/commentRss/340044.htmlhttp://www.aygfsteel.com/unilobster/services/trackbacks/340044.html背景:
在項目中用到用到了多選框的左右移,其中碰到一些問題,記錄下。

下面這是頁面內容


頁面代碼如下
 1 <select multiple="multiple" name=idNoSelectedCode id="idNoSelectedCode" size=10 style="FONT-FAMILY: courier new; FONT-SIZE: 13px; font-weight: bold;width=100%">
 2                 <logic:present name="equipmentList" scope="session">
 3                     <logic:iterate id="rs" name="equipmentList" indexId="varId">
 4                         <option value="<%= varId%>">${rs.eqid}</option>         
<!--這里當時value設的值也是
${rs.eqid},如果有重復的話就會出現問題,所以改成用不會重復的varId-->
 5                     </logic:iterate>
 6                 </logic:present>
 7                 <logic:notPresent name="equipmentList" scope="session">
 8                     <option value="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
 9                 </logic:notPresent>
10             </select>
11             </td>
12             <td width="10%" class="formFieldInput" align="center">
13                 <table><tr><td><input type=button value="->>" onclick="javascript:moveAll('idNoSelectedCode','idSelectedCode');" style="FONT-FAMILY: courier new; FONT-SIZE: 12px">
14                 </td></tr><tr><td><input type=button value="-->" onclick="javascript:srcToDest('idNoSelectedCode','idSelectedCode');" style="FONT-FAMILY: courier new; FONT-SIZE: 12px">
15                 </td></tr><tr><td><input type=button value="<--" onclick="javascript:srcToDest('idSelectedCode','idNoSelectedCode');" style="FONT-FAMILY: courier new; FONT-SIZE: 12px">
16                 </td></tr><tr><td><input type=button value="<<-" onclick="javascript:moveAll('idSelectedCode','idNoSelectedCode');" style="FONT-FAMILY: courier new; FONT-SIZE: 12px">
17                 </td></tr></table>
18             </td>
19             <td width="35%">
20             <select multiple="multiple" name=idSelectedCode id="idSelectedCode" size=10 style="FONT-FAMILY: courier new; FONT-SIZE: 13px; font-weight: bold;width=100%">
21             
22             </select>

實現
關鍵是幾個javascript 函數的實現。
 1 function moveAll(srcid,destid)
 2     {
 3         var optionsObjects=document.getElementById(srcid);
 4         for(var o=0;o<optionsObjects.length;o++)
 5         {
 6             optionsObjects.options[o].selected=true;
 7         }
 8         srcToDest(srcid,destid);
 9     }    
10     function srcToDest(srcid,destid)  
11     {  
12          var optionsObjects=document.getElementById(srcid);
13         var optionsSubObjects=document.getElementById(destid);
14                 
15         for(var o=0;o<optionsObjects.length;o++)
16          {
17              if(optionsObjects.options[o].selected==true)
18               {
19                  var optionsvalue=optionsObjects.options[o].value;
20                  var optionstext=optionsObjects.options[o].text;
21                  addoptions(srcid,destid,optionstext,optionsvalue);
22                  o = o- 1;                                                                                
                      //這里是發生死循環的主要原因,如果沒有重復數據,這里源框會移走一條數據,所以o要減1。
                     //但是當有重復數據時不會移走,導致o-1,下個循環再+1,還是自己本身,死循環發生鳥。

23               }
24          }
25      }
26      
27     function addoptions(srcid,destid,optionstext,optionsvalue)
28      {
29          var optionsObjects=document.getElementById(srcid);
30          var optionsSubObjects=document.getElementById(destid);
31          var hasexist=0;
32          for(var o=0;o<optionsSubObjects.length;o++)
33          {
34               var optionsvalue_sub=optionsSubObjects.options[o].value;
35               if(optionsvalue_sub==optionsvalue)                                 //判斷在目標框中是否存在這個值,這里用select的value才不會出現重復的情況。
36                   hasexist+=1;
37          }
38          if(hasexist==0)
39          {
40               optionsSubObjects.add(new Option(optionstext,optionsvalue));
41               for(var o=0;o<optionsObjects.length;o++)
42              {
43                   var optionsvalue_src=optionsObjects.options[o].value;
44                   if(optionsvalue_src==optionsvalue)                            //判斷在源框中是否存在這個值,這里也必須用select的value。
45                    optionsObjects.options.remove(o);
46              }
47          }
48      }

下面是要取出目標框中我們移過去的值
1 var optionsObjects=document.getElementById("idSelectedCode");
2 
3 for(var o=0;o<optionsObjects.length;o++)
4         {
5             var optionstext=optionsObjects.options[o].text;              //這里用text,因為value并不是我們需要的。
6             equipItemList +=optionstext+";";
7         }

這個equipItemList 就是用分號拼接出來的值,下面是蒸是炒是炸就看你的了。

問題:
一開始的時候我都是用text去比較,結果text的值不可靠,出現重復的情況。然后導致IE彈出”Stop running this script“
,一個運行緩慢的警告框。當時是以為數據太多的原因,后來發現是因為有重復的值導致死循環計算,IE自己彈出運行緩慢的警告。





游雯 2010-12-08 11:07 發表評論
]]>
JavaScript 的 parseInt('08')http://www.aygfsteel.com/unilobster/articles/328729.html游雯游雯Fri, 13 Aug 2010 00:43:00 GMThttp://www.aygfsteel.com/unilobster/articles/328729.htmlhttp://www.aygfsteel.com/unilobster/comments/328729.htmlhttp://www.aygfsteel.com/unilobster/articles/328729.html#Feedback0http://www.aygfsteel.com/unilobster/comments/commentRss/328729.htmlhttp://www.aygfsteel.com/unilobster/services/trackbacks/328729.html 背景:
        在javascript中將字符串轉換成整數時,用到一個函數parseInt。這個函數完整的表達式是:
parseInt(string, radix)

一般情況下,都會省掉第二個參數radix。當遇到轉換“0”開頭的字符串的時候,問題就來了。
    parseInt("01") =1
              ~
    parseInt("07") =7


    parseInt("08") =0
    parseInt("09") =0

    parseInt("10") =10

這是為什么呢?
函數的第一個參數 string 當然是要轉換為數字的字串,第二個參數 radix 則是要用二進位、還是八進位或十六進位,又或是最熟悉的十進位來解譯這個字串呢?

也就是說,如果 parseInt('FF',
16),代表以 16 進位方式來解析FF這個字串,當然得到的結果就是 255 了,同理,parseInt('FF',10) 以 10 進位來解析FF這個字串,根本就不是數字,所以得到的結果會是 NaN。

但大多數人不會特別指定第二個參數,這時 JavaScript 就自動判斷第一個傳遞的參數是否為某種數字型式。

在 JavaScript 眼中,以 0x 開頭的字串,都視為十六進位字串,如果單單是0開頭,第二個字母不是 x,則視為八進位或二進位字串,十六進位使用的字母計有 
0-9,A-F,而八進位使用的字母則為 0-7,所以,當發生parseInt('08') 又未指定以何種數值型態解析時,JavaScript 以 0 為起頭,接下來的字母又不是 x,那一定是八進位了,但是,八進位裡,怎麼可能有 8 和 9 這兩個字母呢?所以,一定是不合法的字串,於是就傳回 0。

同理,parseInt('
010') 回傳的值,也不是 10,而是 8,因為 parseInt() 認為 0 開頭,接下來的字母不是 x,而是 1,就以二進位來解析 010 這個字串,所以一切問題都在於以 0 開頭,所造成的誤會。
注:以上文字來源于http://www.cnblogs.com/zxp_9527/archive/2009/02/27/1399658.html

可以看出來,root cause就是字符串中以“0”開頭了。萬惡零開頭。

解決辦法
        
不能偷懶,該轉換成什么進制就在第二個參數標明,如parseInt("08",10) = 8 這樣就不會錯了。







游雯 2010-08-13 08:43 發表評論
]]>
action跳轉到本地靜態htmlhttp://www.aygfsteel.com/unilobster/articles/319441.html游雯游雯Tue, 27 Apr 2010 03:09:00 GMThttp://www.aygfsteel.com/unilobster/articles/319441.htmlhttp://www.aygfsteel.com/unilobster/comments/319441.htmlhttp://www.aygfsteel.com/unilobster/articles/319441.html#Feedback0http://www.aygfsteel.com/unilobster/comments/commentRss/319441.htmlhttp://www.aygfsteel.com/unilobster/services/trackbacks/319441.html項目新需求:
需要將help鏈接指向到本地配置文件夾里面的一個靜態幫助頁面(hp)。

個人分析:
如果將hp存放在工程目錄下,這個問題就很好解決了。只要用javascript就可以完全控制了。
1     <a href="javascript:openHelp();">Help</a>

1 function openHelp()
2 {
3   window.open("/yourProj/form/hp.html","help","top=0, left=0, toolbar=no,menubar=no, scrollbars=yes, resizable=yes,location=no, status=yes");
4 }
注:hp.html存放路徑是:yourProj/WebContent/form/hp.html

這樣可以在新窗口中彈出hp頁面。

殘酷的現實
需求需要將hp存放在服務器其他文件夾下,如果還用javascript控制,就不知道能不能行了。我試過將window.open()的第一個參數改成hp相應的文件夾絕對路徑,但是javascript報錯,打不開。還有個疑問,如果這樣能行的話,是不是打開是的客戶端電腦上的文件,還是服務器上的文件?

折中辦法:

想了兩個辦法解決:
  • 創建新的action專門用于打開hp頁面。
  • 在系統登錄后,將hp頁面的內容讀取到session中,然后在用戶點擊help鏈接時,從session中讀取文件內容寫到新窗口。
第一種辦法:
jsp
1 <href="<%= basePath %>getHelp.do?" target="_blank">Help</a>
注:關于這個_blank也想了很久,action跳轉本身是直來直去的,利用<a> 的屬性就可以實現在新窗口打開hp頁面。另外插一句,如果是form提交的也可以實現在新頁面打開,只需在submit方法中添加這句話 document.XXXXXXForm.target="_blank";

aciton
 1        String  SystemHelp = "/yourDir/hp.htm";
 2         
 3         File existFile = new File(SystemHelp);
 4         if (!existFile.exists()) {
 5             throw new Exception("file isn't exist: " + SystemHelp);
 6         }
 7 
 8         String mimetype = "text/html;charset=UTF-8";
 9         response.setContentType(mimetype);
10 
11         ServletOutputStream out = response.getOutputStream();
12         FileInputStream fis = new FileInputStream(SystemHelp);
13         BufferedInputStream bis = new BufferedInputStream(fis);
14         
15         byte[] buf = new byte[4096];
16         int len = 0;
17         while ((len = bis.read(buf)) != -1) {
18             out.write(buf, 0, len);
19         }
20         out.flush();
21         out.close();
22         bis.close();
23         fis.close();
24 
25         return mapping.findForward(null);
struts-config.xml
1     <action path="/getHelp" type="youPackage.GetHelpAction">
2             <exception key="help.exception" type="java.lang.Exception" path="yourProj.exception"></exception>
3     </action>
這樣勉強是實現了,但我不知道這是不是最好的辦法,也不知道這樣實現會不會有別的問題,至少目前看沒什么問題。

第二種辦法:
這個辦法就比較土了,是我想破頭想出的辦法。還是用window.open()方法,只不過是打開一個空白的,然后在里面寫入hp.html文件內容。土不土?
在系統登錄成功后,將hp.html的內容讀到session中。
 1         String SystemHelp = "/yourDir/hp.htm";        
 2         File existFile = new File(SystemHelp);
 3         if (existFile.exists()) {
 4             BufferedReader in11 = new BufferedReader(new FileReader(SystemHelp ));
 5             String s;
 6             String links="";
 7             while((s=in11.readLine())!=null){
 8                 links+=s;
 9             }
10             
11             session.setAttribute("helpContent", links);
12         }else{
13             session.setAttribute("helpContent""file isn't exist:" + SystemHelp );
14         }
至于是用String保存文件內容還是String[]還是別的就值得另外探討了。

然后 修改openHelp()函數
1 function openHelp()
2 {
3    openWin=window.open("/yourProj/form/hp.html","help","top=0, left=0, toolbar=no,menubar=no, scrollbars=yes, resizable=yes,location=no, status=yes");
4    openWin.document.write(<%=session.getAttribute("helpContent")%>);
5    openWin.document.close();
6 }
這樣就算是實現了。但是總感覺這個辦法不太合適。

小結:
先把問題列在這里,看看以后能不能再碰到,再思考思考。

-----------最新進展的分割線2010.08.13-------------------------------

用第一種辦法實現之后,出現一個問題。是這樣的,hp文檔里面有很多html頁面互相銜接,而且都是用相對路徑。單單在電腦上用文件形式打開時,各鏈接間跳轉正常,URL是file:///E:/support/SystemHelp.htm。

但當用上面第一種辦法實現的時候,打開第一個hp鏈接是正常的,再點開里面的鏈接就出問題了。原因是就算用第一種辦法實現,打開hp之后的url還是http://yourIP/yourProj/getHelp.do。再之后顯然就不對了。

解決辦法:
建立虛擬目錄。實際上就是將幫組文檔看作一個獨立的Proj系統。這樣就跟本系統獨立開來,而在本系統只需要一個鏈接就可以打開hp。

建立虛擬目錄,按各server的種類稍不一樣。
列舉來說:
hp文檔實際路徑 E:\support
起始文檔:SystemHelp.htm

對Tomcat來說,修改server.xml
在</Context>和</Host>之間添加以下代碼:
<Context path="/yourProjHelp" docBase="e:/support" debug="0" reloadable="true" crossContext="true"></Context>

對Weblogic來說,修改weblogic.xml
添加以下代碼:

<virtual-directory-mapping>
    
<local-path>e:/support</local-path>
    
<url-pattern>/yourProjHelp/*</url-pattern>
</virtual-directory-mapping>
對weblogic按照以上方法,沒有實現成功,有點問題,暫擱再議。


在頁面引用
<href="http://localhost:8080/yourProjHelp/SystemHelp.htm" target="_blank">Help</a>
注對于以上URL,一般不推薦用硬代碼,所以可以按下面這樣修改。

在jsp頭部添加下述定義
<%
//String path 
= request.getContextPath();
String path = yourProjHelp;
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

這樣引用URL就就可以改成
<href="<%= basePath %>SystemHelp.htm" target="_blank">Help</a>


游雯 2010-04-27 11:09 發表評論
]]>
html:image和html:img的區別http://www.aygfsteel.com/unilobster/articles/318925.html游雯游雯Wed, 21 Apr 2010 00:55:00 GMThttp://www.aygfsteel.com/unilobster/articles/318925.htmlhttp://www.aygfsteel.com/unilobster/comments/318925.htmlhttp://www.aygfsteel.com/unilobster/articles/318925.html#Feedback0http://www.aygfsteel.com/unilobster/comments/commentRss/318925.htmlhttp://www.aygfsteel.com/unilobster/services/trackbacks/318925.html

  html:image具有自動提交功能

          如果該標簽在form里,他就可以自動提交表單,雖然你沒有在onclick:"document.form.submit".

         屏蔽此功能可以這樣寫:onclick:"return false"

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

注:其實應該這么寫:onclick:"someFunction();return false"

 

html:img 只是一般的顯示圖片



游雯 2010-04-21 08:55 發表評論
]]>
HashMap遍歷的兩種方式http://www.aygfsteel.com/unilobster/articles/316529.html游雯游雯Thu, 25 Mar 2010 07:08:00 GMThttp://www.aygfsteel.com/unilobster/articles/316529.htmlhttp://www.aygfsteel.com/unilobster/comments/316529.htmlhttp://www.aygfsteel.com/unilobster/articles/316529.html#Feedback0http://www.aygfsteel.com/unilobster/comments/commentRss/316529.htmlhttp://www.aygfsteel.com/unilobster/services/trackbacks/316529.html 方法一
1 Map map = new HashMap();
2 Iterator iter = map.entrySet().iterator();
3 while (iter.hasNext()) {
4     Map.Entry entry = (Map.Entry) iter.next();
5     Object key = entry.getKey();
6     Object val = entry.getValue();
7 }

方法二
1 Map map = new HashMap();
2 Iterator iter = map.keySet().iterator();
3 while (iter.hasNext()) {
4     Object key = iter.next();
5     Object val = map.get(key);
6 }

方法一較方法二效率高


游雯 2010-03-25 15:08 發表評論
]]>
主站蜘蛛池模板: 常熟市| 昌吉市| 瑞昌市| 呼和浩特市| 丹江口市| 木兰县| 安泽县| 尼勒克县| 阿拉善右旗| 日土县| 隆化县| 黄浦区| 青田县| 临武县| 凭祥市| 安阳市| 宝丰县| 云霄县| 鸡东县| 读书| 改则县| 太康县| 漠河县| 衡水市| 大新县| 太仆寺旗| 泸西县| 开江县| 博兴县| 屏东市| 瑞金市| 都兰县| 阳谷县| 清镇市| 左云县| 绥滨县| 如东县| 长沙县| 渝中区| 收藏| 和硕县|