亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 4551 | 回復(fù): 8
打印 上一主題 下一主題

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2002-10-07 23:25 |只看該作者 |倒序瀏覽
最近升級為2顆紅星,昨天又發(fā)現(xiàn)進入排行榜前10名,很高興,于是散點分(別嫌我吝嗇),把java初學(xué)者學(xué)習(xí)總可能用的到問題總結(jié)一下,想對大家有幫助。
1:jdk開發(fā)中系統(tǒng)環(huán)境變量設(shè)置:
方法如下:
Win2000中:
右鍵我的電腦--》屬性--》高級--》環(huán)境環(huán)境變量
classpath=.&#59;jdk安裝目\lib
path=jdk安裝目錄\bin
注意:一定不可忽略“.”。
Win98中:
修改autocexe.bat 就是修改自動批處理文件。
添加:
set classpath=.&#59;jdk安裝目\lib
set path=jdk安裝目錄\bin&#59;%path%

2:(前提設(shè)置好了系統(tǒng)環(huán)境變量)
不帶包的編譯,相當簡單:
javac 類名.java
java 類名

關(guān)于帶包的編譯問題:
如果你的類是帶包的,應(yīng)該用如下方法編譯:
javac -d  包的父目錄 類名.java
java  包名.類名

3:Tomcat服務(wù)器配置:
   1):設(shè)置好系統(tǒng)環(huán)境變量。
   2):JAVA_HOME=G:\JBuilder6\jdk1.3.1
     G:\JBuilder6\jdk1.3.1為jdk安裝目錄
   3):TOMCAT_HOME=tomcat安裝目錄
4:修改serlet而不重新啟動tomcat
修改
%TOMCAT_HOME%\conf\server.xml
大致如下:
<Context path=&quot;&quot; docBase=&quot;ROOT&quot; debug=&quot;0&quot;  reloadable=&quot;true&quot;/>;
其中reloadable就是配置是否自動reload的,把它設(shè)為true,如果沒有這一項,加上。
5:修改webshpere中的servlet而不重新啟動服務(wù):
修改..\WEB-INF下面的web.xml:
加入<webappext:WebAppExtension xmi:version=&quot;2.0&quot; xmlnsmi=&quot;http://www.omg.org/XMI&quot; xmlns:webappext=&quot;webappext.xmi&quot; xmlns:webapplication=&quot;webapplication.xmi&quot; xmlnssi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmi:id=&quot;WebApp_ID_Ext&quot; reloadInterval=&quot;3&quot; reloadingEnabled=&quot;true&quot; fileServingEnabled=&quot;true&quot; directoryBrowsingEnabled=&quot;true&quot; serveServletsByClassnameEnabled=&quot;true&quot;>;其中reloadInterval=&quot;3&quot; reloadingEnabled=&quot;true&quot; fileServingEnabled=&quot;true&quot; directoryBrowsingEnabled=&quot;true&quot; serveServletsByClassnameEnabled=&quot;true&quot;是主要的,reloadInterval=&quot;3&quot; reloadingEnabled=&quot;true&quot; 是說修改后3秒自動重新載
入。
6:配置jbuilder6+webshpere4.0AE,其實jb7可以參照:
首先安裝j2ee,然后把j2ee加入到j(luò)b的libraries里面。方法如下
  1:)tools--->;configure libraries-->;new--->;name:里面填寫j2ee,Location:里面默認的舊可以了。---->;add-->;選在j2ee安裝路徑,選中l(wèi)ib文件夾--ok--oK.
 2返回到configure libraries也面后,選中Required Libraries-->;add--》選中你剛才創(chuàng)建的j2ee,點ok就可以了。
然后配置webshpere應(yīng)用服務(wù)器和database pilot:
第一步:tools-->;enterprise setup-->;Application servers設(shè)置安裝路徑以及IBM的JAVA路徑,DB2你自己看著辦
第二步:project-->;Defaults project properties里servers選擇Ws4.0,應(yīng)該可以用了
webshpere4.0不支持ejb2.0,webshpere5.0支持。
配置database pilot
第一步:添加類庫tools-->;config libraries添加你的數(shù)據(jù)庫驅(qū)動程序類
第二步:tools-->;enterprise setup-->;Database Drivers里面添加你剛添加的那個類庫
第三步:重啟JBilder后,tools-->;database pilot-->;option-->;drivers,添加驅(qū)動程序
第四步:在database pilot點新建就可以了,driver:COM.ibm.db2.jdbc.app.DB2Driver。url:jdbc:db2:db_sdbc.(db_sdbc為服務(wù)器上的db2數(shù)據(jù)庫).

論壇徽章:
0
2 [報告]
發(fā)表于 2002-10-07 23:26 |只看該作者

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷)

7:解決java中文問題:
針對applet和awt:
    1:)
    Font f = new Font(UIResource.getString(      &quot;Default_font&quot,Font.PLAIN,12)&#59;
      UIManager.put(&quot;Label.font&quot;,f)&#59;
      UIManager.put(&quot;Label.foreground&quot;,Color.black)&#59;
      UIManager.put(&quot;Button.font&quot;,f)&#59;
      UIManager.put(&quot;Menu.font&quot;,f)&#59;
      UIManager.put(&quot;MenuItem.font&quot;,f)&#59;
      UIManager.put(&quot;List.font&quot;,f)&#59;
      UIManager.put(&quot;CheckBox.font&quot;,f)&#59;
      UIManager.put(&quot;RadioButton.font&quot;,f)&#59;
      UIManager.put(&quot;ComboBox.font&quot;,f)&#59;
      UIManager.put(&quot;TextArea.font&quot;,f)&#59;


    2:)
      Font f = new Font(&quot;隸書&quot;,Font.PLAIN,15)&#59;
           UIManager.put(&quot;Button.font&quot;,font)&#59;
  UIManager.put(&quot;ToggleButton.font&quot;,font)&#59;
  UIManager.put(&quot;RadioButton.font&quot;,font)&#59;
  UIManager.put(&quot;CheckBox.font&quot;,font)&#59;
  UIManager.put(&quot;ColorChooser.font&quot;,font)&#59;
  UIManager.put(&quot;ToggleButton.font&quot;,font)&#59;
  UIManager.put(&quot;ComboBox.font&quot;,font)&#59;
  UIManager.put(&quot;ComboBoxItem.font&quot;,font)&#59;
  UIManager.put(&quot;InternalFrame.titleFont&quot;,font)&#59;
  UIManager.put(&quot;Label.font&quot;,font)&#59;
  UIManager.put(&quot;List.font&quot;,font)&#59;
  UIManager.put(&quot;MenuBar.font&quot;,font)&#59;
  UIManager.put(&quot;Menu.font&quot;,font)&#59;
  UIManager.put(&quot;MenuItem.font&quot;,font)&#59;
  UIManager.put(&quot;RadioButtonMenuItem.font&quot;,font)&#59;
  UIManager.put(&quot;CheckBoxMenuItem.font&quot;,font)&#59;
  UIManager.put(&quotopupMenu.font&quot;,font)&#59;
  UIManager.put(&quot;OptionPane.font&quot;,font)&#59;
  UIManager.put(&quotanel.font&quot;,font)&#59;
  UIManager.put(&quotrogressBar.font&quot;,font)&#59;
  UIManager.put(&quot;ScrollPane.font&quot;,font)&#59;
  UIManager.put(&quot;Viewport&quot;,font)&#59;
  UIManager.put(&quot;TabbedPane.font&quot;,font)&#59;
  UIManager.put(&quot;TableHeader.font&quot;,font)&#59;
  UIManager.put(&quot;TextField.font&quot;,font)&#59;
  UIManager.put(&quotasswordFiled.font&quot;,font)&#59;
  UIManager.put(&quot;TextArea.font&quot;,font)&#59;
  UIManager.put(&quot;TextPane.font&quot;,font)&#59;
  UIManager.put(&quot;EditorPane.font&quot;,font)&#59;
  UIManager.put(&quot;TitledBorder.font&quot;,font)&#59;
  UIManager.put(&quot;ToolBar.font&quot;,font)&#59;
  UIManager.put(&quot;ToolTip.font&quot;,font)&#59;
  UIManager.put(&quot;Tree.font&quot;,font)&#59;

。常海┽槍sp和servlet:
解決辦法:
第一:
在jsp頁面加入:
<%@ page contentType=&quot;text/html&#59; charset=gb2312&quot; %>;
或者在servlet里面
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType(&quot;text/html&#59; charset=gb2312&quot&#59;//這是重要的
上面的如果在不行就用如下的方法在數(shù)據(jù)入庫前進行調(diào)用:
public static String UnicodeToChinese(String s){
  try{
     if(s==null||s.equals(&quot;&quot) return &quot;&quot;&#59;
     String newstring=null&#59;
     newstring=new String(s.getBytes(&quot;ISO8859_1&quot,&quot;gb2312&quot&#59;
     return newstring&#59;
    }
  catch(UnsupportedEncodingException e)
  {
  return s&#59;
  }
  }

public static String ChineseToUnicode(String s){
  try{
  if(s==null||s.equals(&quot;&quot) return &quot;&quot;&#59;
  String newstring=null&#59;
  newstring=new String(s.getBytes(&quot;gb2312&quot,&quot;ISO8859_1&quot&#59;
   return newstring&#59;
  }
  catch(UnsupportedEncodingException e)
  {
  return s&#59;
}
  }

3解決weblogic/webshpere中文問題:
在web.xml文件中需要配置中文環(huán)境。r如下:
<context-param>;
  <param-name>;weblogic.httpd.inputCharset./*</param-name>;
  <param-value>;GB2312</param-value>;
</context-param>;
  4:)javamail附件中文亂碼:
/*
        @從BodyPart中提取使用ISO-8859-1編嗎的文件名
        @因為BodyPart.getFilename()過程已經(jīng)對文件名作了一次編碼,有時不能直接使用
    */
    public static String getISOFileName(Part body){
        //設(shè)置一個標志,判斷文件名從Content-Disposition中獲取還是從Content-Type中獲取
        boolean flag=true&#59;
        if(body==null){
            return null&#59;
        }
        String[] cdis&#59;
        try{
            cdis=body.getHeader(&quot;Content-Disposition&quot&#59;
        }
        catch(Exception e){
            return null&#59;
        }
        if(cdis==null){
            flag=false&#59;
        }
        if(!flag){
            try{
                cdis=body.getHeader(&quot;Content-Type&quot&#59;
            }
            catch(Exception e){
                return null&#59;
            }
        }
        if(cdis==null){
            return null&#59;
        }
        if(cdis[0]==null){
            return null&#59;
        }
        //從Content-Disposition中獲取文件名
        if(flag){
            int pos=cdis[0].indexOf(&quot;filename=&quot;)&#59;
            if(pos<0){
                return null&#59;
            }
            //如果文件名帶引號
            if(cdis[0].charAt(cdis[0].length()-1)=='&quot;'){
                return cdis[0].substring(pos+10,cdis[0].length()-1)&#59;
            }
            return cdis[0].substring(pos+9,cdis[0].length())&#59;
        }
        else{
            int pos=cdis[0].indexOf(&quot;name=&quot;)&#59;
            if(pos<0){
                return null&#59;
            }
            //如果文件名帶引號
            if(cdis[0].charAt(cdis[0].length()-1)=='&quot;'){
                return cdis[0].substring(pos+6,cdis[0].length()-1)&#59;
            }
            return cdis[0].substring(pos+5,cdis[0].length())&#59;
        }
    }
8:字符串分割:
    public int getCount(String str,String sign){//查找某一字符串中str,特定子串s的出現(xiàn)次數(shù)
      if(str==null) return 0&#59;
      StringTokenizer s=new StringTokenizer(str,sign)&#59;
      return s.countTokens()&#59;
  }
 public String[] getArray(String str,String sign){//按特定子串s為標記,將子串截成數(shù)組。
    int count=getCount(str,sign)&#59;
    int j=0&#59;
    String[] arr=new String[count]&#59;
    for(int i=0&#59;i<count&#59;i++){
       if(str.indexOf(sign)!=-1){
            j     =str.indexOf(sign)&#59;
            arr=str.substring(0,j)&#59;
            str   =str.substring(j+1)&#59;
        }else{
            arr=str&#59;
        }
    }
    return arr&#59;

}
9:jdk1.3沒有字符串替換函數(shù),(jdk1.4有)。
解決1.3中的個這個問題如下:

public String stringReplace(String sourceString, String toReplaceString, String replaceString)
  {
    String returnString = sourceString&#59;
    int stringLength = 0&#59;
    if(toReplaceString != null)
    {
      stringLength = toReplaceString.length()&#59;
    }
    if(returnString != null &amp;&amp; returnString.length() >; stringLength)
    {
      int max = 0&#59;
      String S4 = &quot;&quot;&#59;
      for(int i = 0&#59; i < sourceString.length()&#59; i++)
      {
        max = i + toReplaceString.length() >; sourceString.length()? sourceString.length():i + stringLength&#59;
        String S3 = sourceString.substring(i, max)&#59;
        if(!S3.equals(toReplaceString))
        {
          S4 += S3.substring(0,1)&#59;
        }else{
          S4 += replaceString&#59;
          i += stringLength -1 &#59;
        }
      }
      returnString = S4&#59;
    }
    return returnString&#59;
  }
9:設(shè)置weblogic連接池:

pool的配置:
假設(shè)已配置服務(wù):expserv
且數(shù)據(jù)庫服務(wù)器機器名為:expserv
數(shù)據(jù)庫sid:expservSID,用戶名和密碼都為:expserv
以weblogic7.0為例,首先啟動服務(wù)
http://localhost:port/console
打開service\jdbc\connection pools
配置oraclePool如下:
Configuration:
   Name: oraclePool
   URL: jdbcracle:thinexpserv:1521:expservSID
   Driver Classname: oracle.jdbc.driver.OracleDriver  
   Properties(key=value): user=expserv
Targets:
   Targets-Server:expserv
在weblogic7.0中除了數(shù)據(jù)庫密碼,其他的pool參數(shù)都可以在config.xml中直接用文本編輯器直接修改。

論壇徽章:
0
3 [報告]
發(fā)表于 2002-10-07 23:26 |只看該作者

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷)

10:數(shù)字轉(zhuǎn)貨幣大寫(js)
function ChangeToBig(value)
{
var intFen,i&#59;
var strArr,strCheck,strFen,strDW,strNum,strBig,strNow&#59;

if(trim(value)==&quot;&quot   //數(shù)據(jù)為空時返回&quot;零&quot;
return &quot;零&quot;&#59;
if (isNaN(value))   //數(shù)據(jù)非法時提示,并返回空串
{
strErr = &quot;數(shù)據(jù)&quot;+value+&quot;非法!&quot;
alert(strErr)&#59;
return &quot;&quot;&#59;
}
strCheck = value+&quot;.&quot;&#59;
strArr = strCheck.split(&quot;.&quot&#59;
strCheck = strArr[0]&#59;
if(strCheck.length>;12)   //數(shù)據(jù)大于等于一萬億時提示無法處理
{
strErr = &quot;數(shù)據(jù)&quot;+value+&quot;過大,無法處理!&quot;
alert(strErr)&#59;
return &quot;&quot;&#59;
}
try
{
i = 0&#59;
strBig = &quot;&quot;&#59;
intFen = value*100&#59;          //轉(zhuǎn)換為以分為單位的數(shù)值
strFen = intFen.toString()&#59;
strArr = strFen.split(&quot;.&quot&#59;
strFen = strArr[0]&#59;
intFen = strFen.length&#59;      //獲取長度
strArr = strFen.split(&quot;&quot&#59;//將各個數(shù)值分解到數(shù)組內(nèi)
while(intFen!=0)   //分解并轉(zhuǎn)換
{
i = i+1&#59;
switch(i)              //選擇單位
{
case 1:strDW = &quot;分&quot;&#59;break&#59;
case 2:strDW = &quot;角&quot;&#59;break&#59;
case 3:strDW = &quot;元&quot;&#59;break&#59;
case 4:strDW = &quot;拾&quot;&#59;break&#59;
case 5:strDW = &quot;佰&quot;&#59;break&#59;
case 6:strDW = &quot;仟&quot;&#59;break&#59;
case 7:strDW = &quot;萬&quot;&#59;break&#59;
case 8:strDW = &quot;拾&quot;&#59;break&#59;
case 9:strDW = &quot;佰&quot;&#59;break&#59;
case 10:strDW = &quot;仟&quot;&#59;break&#59;
case 11:strDW = &quot;億&quot;&#59;break&#59;
case 12:strDW = &quot;拾&quot;&#59;break&#59;
case 13:strDW = &quot;佰&quot;&#59;break&#59;
case 14:strDW = &quot;仟&quot;&#59;break&#59;
}
switch (strArr[intFen-1])              //選擇數(shù)字
{
case &quot;1&quot;:strNum = &quot;壹&quot;&#59;break&#59;
case &quot;2&quot;:strNum = &quot;貳&quot;&#59;break&#59;
case &quot;3&quot;:strNum = &quot;叁&quot;&#59;break&#59;
case &quot;4&quot;:strNum = &quot;肆&quot;&#59;break&#59;
case &quot;5&quot;:strNum = &quot;伍&quot;&#59;break&#59;
case &quot;6&quot;:strNum = &quot;陸&quot;&#59;break&#59;
case &quot;7&quot;:strNum = &quot;柒&quot;&#59;break&#59;
case &quot;8&quot;:strNum = &quot;捌&quot;&#59;break&#59;
case &quot;9&quot;:strNum = &quot;玖&quot;&#59;break&#59;
case &quot;0&quot;:strNum = &quot;零&quot;&#59;break&#59;
}

//處理特殊情況
strNow = strBig.split(&quot;&quot&#59;
//分為零時的情況
if((i==1)&amp;&amp;(strArr[intFen-1]==&quot;0&quot)
strBig = &quot;整&quot;&#59;
//角為零時的情況
else if((i==2)&amp;&amp;(strArr[intFen-1]==&quot;0&quot)
{    //角分同時為零時的情況
if(strBig!=&quot;整&quot
strBig = &quot;零&quot;+strBig&#59;
}
//元為零的情況
else if((i==3)&amp;&amp;(strArr[intFen-1]==&quot;0&quot)
strBig = &quot;元&quot;+strBig&#59;
//拾-仟中一位為零且其前一位(元以上)不為零的情況時補零
else if((i<7)&amp;&amp;(i>;3)&amp;&amp;(strArr[intFen-1]==&quot;0&quot&amp;&amp;(strNow[0]!=&quot;零&quot;)&amp;&amp;(strNow[0]!=&quot;元&quot;))
strBig = &quot;零&quot;+strBig&#59;
//拾-仟中一位為零且其前一位(元以上)也為零的情況時跨過
else if((i<7)&amp;&amp;(i>;3)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;零&quot;))
{}
//拾-仟中一位為零且其前一位是元且為零的情況時跨過
else if((i<7)&amp;&amp;(i>;3)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;元&quot;))
{}
//當萬為零時必須補上萬字
else if((i==7)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;))
strBig =&quot;萬&quot;+strBig&#59;
//拾萬-仟萬中一位為零且其前一位(萬以上)不為零的情況時補零
else if((i<11)&amp;&amp;(i>;7)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]!=&quot;零&quot;)&amp;&amp;(strNow[0]!=&quot;萬&quot;))
strBig = &quot;零&quot;+strBig&#59;
//拾萬-仟萬中一位為零且其前一位(萬以上)也為零的情況時跨過
else if((i<11)&amp;&amp;(i>;7)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;萬&quot;))
{}
//拾萬-仟萬中一位為零且其前一位為萬位且為零的情況時跨過
else if((i<11)&amp;&amp;(i>;7)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;零&quot;))
{}
//萬位為零且存在仟位和十萬以上時,在萬仟間補零
else if((i<11)&amp;&amp;(i>;&amp;&amp;(strArr[intFen-1]!=&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;萬&quot;)&amp;&amp;(strNow[2]==&quot;仟&quot;))
strBig = strNum+strDW+&quot;萬零&quot;+strBig.substring(1,strBig.length)&#59;
//單獨處理億位
else if(i==11)
{
//億位為零且萬全為零存在仟位時,去掉萬補為零
if((strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;萬&quot;)&amp;&amp;(strNow[2]==&quot;仟&quot;))
strBig =&quot;億&quot;+&quot;零&quot;+strBig.substring(1,strBig.length)&#59;
//億位為零且萬全為零不存在仟位時,去掉萬
else if((strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;萬&quot;)&amp;&amp;(strNow[2]!=&quot;仟&quot;))
strBig =&quot;億&quot;+strBig.substring(1,strBig.length)&#59;
//億位不為零且萬全為零存在仟位時,去掉萬補為零
else if((strNow[0]==&quot;萬&quot;)&amp;&amp;(strNow[2]==&quot;仟&quot;))
strBig = strNum+strDW+&quot;零&quot;+strBig.substring(1,strBig.length)&#59;
//億位不為零且萬全為零不存在仟位時,去掉萬
else if((strNow[0]==&quot;萬&quot;)&amp;&amp;(strNow[2]!=&quot;仟&quot;))
strBig = strNum+strDW+strBig.substring(1,strBig.length)&#59;
//其他正常情況
else
strBig = strNum+strDW+strBig&#59;
}
//拾億-仟億中一位為零且其前一位(億以上)不為零的情況時補零
else if((i<15)&amp;&amp;(i>;11)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]!=&quot;零&quot;)&amp;&amp;(strNow[0]!=&quot;億&quot;))
strBig = &quot;零&quot;+strBig&#59;
//拾億-仟億中一位為零且其前一位(億以上)也為零的情況時跨過
else if((i<15)&amp;&amp;(i>;11)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;億&quot;))
{}
//拾億-仟億中一位為零且其前一位為億位且為零的情況時跨過
else if((i<15)&amp;&amp;(i>;11)&amp;&amp;(strArr[intFen-1]==&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;零&quot;))
{}
//億位為零且不存在仟萬位和十億以上時去掉上次寫入的零
else if((i<15)&amp;&amp;(i>;11)&amp;&amp;(strArr[intFen-1]!=&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;零&quot;)&amp;&amp;(strNow[1]==&quot;億&quot;)&amp;&amp;(strNow[3]!=&quot;仟&quot;))
strBig = strNum+strDW+strBig.substring(1,strBig.length)&#59;
//億位為零且存在仟萬位和十億以上時,在億仟萬間補零
else if((i<15)&amp;&amp;(i>;11)&amp;&amp;(strArr[intFen-1]!=&quot;0&quot;)&amp;&amp;(strNow[0]==&quot;零&quot;)&amp;&amp;(strNow[1]==&quot;億&quot;)&amp;&amp;(strNow[3]==&quot;仟&quot;))
strBig = strNum+strDW+&quot;億零&quot;+strBig.substring(2,strBig.length)&#59;
else
strBig = strNum+strDW+strBig&#59;
strFen = strFen.substring(0,intFen-1)&#59;
intFen = strFen.length&#59;
strArr = strFen.split(&quot;&quot;)&#59;
}
return strBig&#59;
}catch(err){
return &quot;&quot;&#59;      //若失敗則返回原值
}
}


希望這寫方法對大家有幫助。暫時就想到這些,以后想到了,在補充。

論壇徽章:
0
4 [報告]
發(fā)表于 2002-10-07 23:27 |只看該作者

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷)

11:刪除文件夾下的所有目錄:
/*
* 刪除一個目錄下的所有文件
*/  
public static void delAllFile(String path) {
File file = new File(path)&#59;
if(!file.exists()) return&#59;
if(!file.isDirectory()) return&#59;
String[] tempList = file.list()&#59;
File temp = null&#59;
for(int i = 0&#59; i < tempList.length&#59; i++) {
if(path.endsWith(File.separator))
temp = new File(path + tempList)&#59;
else
temp = new File(path + File.separator + tempList)&#59;
if(temp.isFile()) temp.delete()&#59;
if(temp.isDirectory()) delAllFile(path + tempList)&#59;
}
}
12:字符串轉(zhuǎn)換成時間及時間相減:
    1 SimpleDateFormat formatter = new SimpleDateFormat (&quot;yyyy.MM.dd&quot&#59;
        //假定像2002.07.04的是合法日期其他都非法。
    String str=&quot;2002.07.04&quot;&#59;
    ParsePosition pos = new ParsePosition(0)&#59;
    Date dt=formatter.parse(str,pos)&#59;
   if(dt!=null)
   {
     //是合法日期
   }
    else
   {
     //非法日期
   }
2
兩個日期相減
import java.util.*&#59;
import java.text.*&#59;
class a
{
public static void main(String[] args)
{
String s1 = &quot;2003/08/15 17:15:30&quot;&#59;
String s2 = &quot;2002/09/14 14:18:37&quot;&#59;
try{
SimpleDateFormat formatter = new SimpleDateFormat (&quot;yyyy/MM/dd HH:mm:ss&quot&#59;

ParsePosition pos = new ParsePosition(0)&#59;
ParsePosition pos1 = new ParsePosition(0)&#59;
Date dt1=formatter.parse(s1,pos)&#59;
Date dt2=formatter.parse(s2,pos1)&#59;
System.out.println(&quot;dt1=&quot;+dt1)&#59;
System.out.println(&quot;dt2=&quot;+dt2)&#59;
long l = dt1.getTime() - dt2.getTime()&#59;

System.out.println(&quot;Hello World!=&quot;+l)&#59;
}catch(Exception e){
System.out.println(&quot;exception&quot;+e.toString())&#59;
}

}
}


3得到2個月后的日期:
import java.util.*&#59;
import java.text.DateFormat&#59;
public class test2
{
public static void main(String args[]) throws Exception
{
String date=&quot;2001/11/30&quot;&#59;

DateFormat dateFormat =
DateFormat.getDateInstance(DateFormat.MEDIUM)&#59;
GregorianCalendar grc=new GregorianCalendar()&#59;
grc.setTime(new Date(date))&#59;


grc.add(GregorianCalendar.MONTH,2)&#59;
System.out.println(&quot;grc=&quot;+dateFormat.format(grc.getTime()))&#59;
}
}

13:jsp/servet重定向問題:
不改變url的:
  1:)servlet:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

      getServletContext().getRequestDispatcher(test2URL).forward(request, response)&#59;
2jsp
  <jsp:forward page=&quot;/jsp/forward/one.jsp&quot;/>;
改變url的:
  1:)response.sendRedirect(&quot;/web/mail/pop3.jsp&quot&#59;

論壇徽章:
0
5 [報告]
發(fā)表于 2002-10-07 23:27 |只看該作者

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷)

14:jb7+weblogic6.x配置方法如下:
Win 2000 Temp、Tmp 的配置

因為我們生成的 ejb 相關(guān)代碼要進行一系列的編譯,那么所生成的臨時文件就要有個地方放啊,但 Win2000中的 Temp、Tmp 目錄卻偏偏有空格 如%USERPROFILE%\Local Settings\Temp,接下來我們來配置一下:

1) 右擊 《我的電腦》 選屬性,在彈出的對話框中選 《高級》 ,再選 《環(huán)境變量》 按鈕,

2) 修改 《Administrator 的用戶變量》和《系統(tǒng)變量》中的 TEMP、TEMP、TMPDIR 選項,單擊每一個選項,然后點《編輯》(右圖),把每個 變量名為  TEMP、TEMP、TMPDIR 的值都改為 c:\WINNT\temp ,當然這不是必須的,只是我建議你這么做。

其實也沒什么難的,若改完,則Win2000環(huán)境這么應(yīng)該沒什么問題了。
WebLogic 6.X 部分

一、JDBC Connection Pool 的配置    以Mysql 小型數(shù)據(jù)庫為例

在進行此項配置之前,先將欲使用的 數(shù)據(jù)庫JDBC 驅(qū)動 Jar 文件放到D:\bea\wlserver6.1\lib\jdbc 目錄下(建議這樣做,沒有jdbc目錄就建一個唄),然后編輯D:\bea\wlserver6.1\config\mydomain 下的 startWebLogic.cmd 文件,在 classpath 中加入數(shù)據(jù)庫的JDBC驅(qū)動文件,如紅字部分:

:runWebLogic
echo on
set PATH=.\bin&#59;.\bin\oci817_8&#59;d:\oracle\ora81\bin&#59;%PATH%
set CLASSPATH=.\lib\cr_wls60f.jar&#59;.\lib\weblogic_sp.jar&#59;.\lib\weblogic.jar&#59;.\lib\jdbc\mysql.jar

這樣 Weblogic 啟動時才會加載欲使用的數(shù)據(jù)庫JDBC驅(qū)動,配置也才會正常,否則會報錯。
1)在Weblogic控制臺中依次展開Services \ JDBC \ Connection Pools
2)單擊 Configure a new JDBC Connection Pool...

3)填入每一項參數(shù),結(jié)果如下:
url: jdbc:mysql://127.0.0.1:3306/test
driver classnamerg.gjt.mm.mysql.Driver
properties(key=value):user=root
4) 別忘了點一下 Apply 即應(yīng)用一下:)
5) Connections 簽下的 初始容量、最大容量、容量增長等可根據(jù)自已需要配置
6) 還有至關(guān)重要的最后一步,我們做的以上配置工作還沒有真正的應(yīng)用到 Weblogic 上,所以還差一步,
    選 Targets 簽,選 Servers 簽,選 Available (可用)中的 myserver ,然后點&quot;-->;&quot;  ,再點 Apply 應(yīng)用一下。
    這樣我們所做的工作才會真正有效, Weblogic 也才會認識我們配置的 JDBC Connection Pool
二、配置數(shù)據(jù)源

1)在Weblogic控制臺中依次展開Services \ JDBC \ Tx Data Sources
2)單擊 Configure a new JDBC Tx Data Source...
3)填入每一項參數(shù),結(jié)果如下:

jndi name: MysqlDataSoruce
PoolName:MysqlPool
row prefetch size :48
stream chunk size: 2564) 別忘了點一下 Apply 即應(yīng)用一下:)
5) 同樣,選 Targets 簽,選 Servers 簽,選 Available (可用)中的 myserver ,然后點&quot;-->;&quot;  ,再點 Apply 應(yīng)用一下。
    這樣我們所做的工作才會真正有效, Weblogic 也才會認識我們配置的 DataSource。

JBuilder 7 的相關(guān)配置

一、數(shù)據(jù)庫驅(qū)動的加載

同 weblogic 一樣,在進行此項配置之前,先將欲使用的 數(shù)據(jù)庫JDBC 驅(qū)動 Jar 文件放到 D:\JBuilder7\lib\jdbc 目錄下(建議這樣做,沒有jdbc目錄就建一個唄)

1) 開啟 JBuilder 7,單擊 Tools \ EnterPrise Setup .......

2) 在彈出窗口中選擇 Database Drivers 簽
3) 再點 Add 按鈕,彈出新窗口(可能你的與圖上的略有不同)
4) 再單擊 New ... 按鈕,彈出新窗口,并改變 Name: 的默認值為 mysql (只要有意義,起個什么名都成)
5) 單擊 Add... 按鈕來查找并添加數(shù)據(jù)庫的 JDBC 驅(qū)動,當然了,我們到 D:\JBuilder7\lib\jdbc 下去找,選 mysql.jar ,注意,不要把mysql.jar 展開,象圖那樣選中再按 OK 就行了。
提示:可以配合 Shift 和 Ctrl 鍵同時選多個 .jar 文件。
6) 結(jié)果如下圖,如果有多個需要添加的 .jar 文件,還可點 Add... 按鈕繼續(xù)添加。
7) OK 退出.
再OK ,則 mysql JDBC 驅(qū)動就已經(jīng)加入了。
9) 再一次的 Ok ,JBuilder 提示要重起后上述配置才會生效,確定并重啟 JBuilder。
二、EJB 2.0 和 應(yīng)用服務(wù)器的配置,以 WebLogic 6.X為例

在進行此項配置之前要安裝 Borland Enterprise Servler 5.02 ,IAS 4.5 也成,它倆是一回事,當然了我是有新的不用舊的,安裝過程略,因為安裝它很 easy ! 基本是一路回車,我把我的安裝在 D:\BorlandEnterpriseServer 下了。

1) 開啟 JBuilder 7,單擊 Tools \ EnterPrise Setup .......

2) 選擇 CORBA 簽,在 Configuration 下的下拉列表框,選擇 VisiBroker

3) 選擇 Edit... ,彈出 Edit Confiuration 窗口
  點擊path for orb tools
4) 單擊 Path for ORB tools: 旁邊的 ... 瀏覽按鈕,彈出 Select Directory 窗口,選擇 D:\BorlandEnterpriseServer5\bin 并 OK。

5) 再 兩遍 OK ,JBuilder 又要求你重啟,沒辦法,照它說的做,重啟 JBuilder 。

6) 重啟后,還要到 Tools \ EnterPrise Setup ....... ,選 CORBA 項,選 Edit ,在彈出窗口中選 Library for projects: 旁邊的 ... 按鈕
7) 在彈出的新窗口的 User Home 中你會發(fā)現(xiàn)多了一個選項 Borland Enterprise Server 5.0.2+ Client
    即 選擇圖中所示 黑亮的選項,然后 三遍 OK 退出。
再選擇 Project \ Default Project Properties 項
9) 在彈了對話框中選 Server 簽,如圖,點擊 ... 按鈕,
10) 在彈出的新對話框中,選擇 WebLogic Application Server 6.x +,然后復(fù)選 Enable server ,見圖中紅框。
11) 復(fù)選 Enable server 后,其它各項可選或可填,點擊 ... 按鈕,
    選擇 Home directory ;
    選擇 Working directory ;
    為你機器所裝 Weblogic 的位置。
12) 點擊 Class 簽內(nèi)的Add 按鈕,如上圖,將 D:\bea\wlserver6.1\lib\cr_wls60f.jar 文件添加進來。如上圖紅線。
    再用 Move Up 按鈕,將  D:\bea\wlserver6.1\lib\cr_wls60f.jar 文件移至最項端,因為一般后加的 .jar 文件在最下邊。
    這一步也比較重要,因為在JBuilder 環(huán)境下可以直接啟動 Weblogic ,那它就要首先檢測 license 是否合法,即 cr_wls60f.jar文件
    是否存在。

13) 再選擇 Custom 簽,按如下紅線所示配置,可能您裝的 Weblogic 目錄位置與我的有不同,但大概意思是一樣的。
    配置完后,點擊 OK 按鈕退出
   domain name :mydomain
   server name: myserver
   version:6.1 Service Pack1(d:/bea/wlserver6.1)
14) 再在如圖窗口中的 Single server for all services in project 下拉列表框中選擇 WebLogic Application Server 6.x+ 如圖所示,然后 OK 退出。
15) 至此 JBuiler 7 下與 WebLogic 6.x 的配置完成,那我們就開工吧!

本配置有csdn-wjmmml(笑著悲傷)整理。我花了好長時間哦。如轉(zhuǎn)載請不要刪除本行。

論壇徽章:
0
6 [報告]
發(fā)表于 2002-10-07 23:28 |只看該作者

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷)

俺接著來,呵呵:
15.計算日期間隔
public int getDays(Date sd,Date ed){
  return (ed.getTime()-sd.getTime())/(3600*24*1000)
}

16.日期加減
SimpleDateFormat sdf=new SimpleDateFormat(&quot;yyyyMMdd&quot&#59;
String str=&quot;20011230&quot;&#59;
Date dt=sdf.parse(str,new ParsePosition(0))&#59;
Calendar rightNow = Calendar.getInstance()&#59;
rightNow.setTime(dt)&#59;
rightNow.add(Calendar.DATE,2)&#59;//你要加減的日期
Date dt1=rightNow.getTime()&#59;
String reStr=sdf.format(dt1,&quot;&quot;,new FieldPosition(0))&#59;
System.out.println(reStr)&#59;

17.時間顯示控制   
第一種方式:
<html>;
<head>;<title>;取得系統(tǒng)時間</title>;</head>;
<body>;
<%java.util.Date date=new java.util.Date()&#59;%>;
現(xiàn)在是:<%=date%>;
</body>;
</html>;
運行結(jié)果:
現(xiàn)在是:Tue Jul 31 10:32:52 CST 2001

第二種方式:
<%@ page import=&quot;java.util.*, java.text.*&quot; %>;
<HTML>;
<HEAD>;<TITLE>;顯示當前時間</TITLE>;</HEAD>;
<BODY>;
當前時間:
<%
Date now = new Date()&#59;
out.println(DateFormat.getTimeInstance().format(now))&#59;
%>;
</BODY>;
</HTML>;
運行結(jié)果:
10:31:42 AM

第三種方式:
<%
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(&quot;yyyy年MM月dd日&quot&#59;
java.util.Date currentTime_1 = new java.util.Date()&#59;
out.print(formatter.format(currentTime_1))&#59;
%>;
運行結(jié)果:
2001年07月31日

第四種方式:
<%
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(&quot;yyyy/MM/dd HH/mm/ss&quot&#59;
java.util.Date currentTime_1 = new java.util.Date()&#59;
out.print(formatter.format(currentTime_1))&#59;
%>;
運行結(jié)果:
2001/07/31 10/32/52
第三四兩種方式其實是一樣的他可以產(chǎn)生千變?nèi)f化的格式。



18.加密&amp;解密
在插入數(shù)據(jù)庫前先將字符串str進行加密:
java.net.URLEncoder.encode(String str)&#59;
從數(shù)據(jù)庫中取出時再解碼:(可以先不加密,只解碼,試一試;不行再加密)
java.net.URLDecoder.decode(String str)&#59;

19.頁面刷新:
有三種方法:
1,在html中設(shè)置:
<title>;xxxxx</title>;之後加入下面這一行即可!
定時刷新:<META HTTP-EQUIV=&quot;Refresh&quot; content=&quot;10&#59; URL=http://自己的URL&quot;>;
10代表刷新間隔

2.jsp
<% response.setHeader(&quot;refresh&quot;,&quot;1&quot&#59; %>;
  沒一秒刷新一次

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

20.打。
1.直接調(diào)用windows函數(shù)
<input type=&quot;button&quot; value=&quot;print&quot;
onclick=&quot;window.focus()&#59;window.print()&quot;>;

2.調(diào)用js
//放在head 與 head 之間
<SCRIPT LANGUAGE=javascript>;
<!--
function setPrint()
{
WB.ExecWB(8,1)&#59;
}
function previewPrint()
{
WB.ExecWB(7,1)
}
//-->;
</SCRIPT>;

//放在body與body之間
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0>;
</OBJECT>;
<INPUT type=&quot;button&quot; value=&quot;打印設(shè)置&quot; id=button1 name=button1 onclick=&quot;setPrint()&#59;&quot;>;
<INPUT type=&quot;button&quot; value=&quot;打印預(yù)覽&quot; id=button2 name=button2 onclick=&quot;previewPrint()&#59;&quot;>;

21.將數(shù)據(jù)用execl在客戶端展現(xiàn):
<style type=&quot;text/css&quot;>;
{
  .showTD {color: #003366&#59; }
  .hiddenTD {display:none&#59; }
  .onFocue  {color: #CC66FF&#59;}
  .offFocue {color:#003366&#59;}
}
#floater {
    LEFT: 445px&#59; POSITION: absolute&#59; TOP: 15px&#59; VISIBILITY: visible&#59; WIDTH: 125px&#59; Z-INDEX: 10}
</STYLE>;

<object classid=&quot;clsid:0002E510-0000-0000-C000-000000000046&quot; id=&quot;Spreadsheet1&quot; width=&quot;676&quot; height=&quot;388&quot;>;
  <param name=&quot;HTMLURL&quot; value>;
  <param name=&quot;HTMLData&quot; value=&quot;&quot;>;
  <param name=&quot;DataType&quot; value=&quot;HTMLDATA&quot;>;
  <param name=&quot;AutoFit&quot; value=&quot;0&quot;>;
  <param name=&quot;DisplayColHeaders&quot; value=&quot;-1&quot;>;
  <param name=&quot;DisplayGridlines&quot; value=&quot;-1&quot;>;
  <param name=&quot;DisplayHorizontalScrollBar&quot; value=&quot;-1&quot;>;
  <param name=&quot;DisplayRowHeaders&quot; value=&quot;-1&quot;>;
  <param name=&quot;DisplayTitleBar&quot; value=&quot;-1&quot;>;
  <param name=&quot;DisplayToolbar&quot; value=&quot;-1&quot;>;
  <param name=&quot;DisplayVerticalScrollBar&quot; value=&quot;-1&quot;>;
  <param name=&quot;EnableAutoCalculate&quot; value=&quot;-1&quot;>;
  <param name=&quot;EnableEvents&quot; value=&quot;-1&quot;>;
  <param name=&quot;MoveAfterReturn&quot; value=&quot;-1&quot;>;
  <param name=&quot;MoveAfterReturnDirection&quot; value=&quot;0&quot;>;
  <param name=&quot;RightToLeft&quot; value=&quot;0&quot;>;
  <param name=&quot;ViewableRange&quot; value=&quot;1:65536&quot;>;
</object>;
<div class=&quot;hiddenTD&quot; id=&quot;tablers&quot;>;
<table width=95% align=center border=1 cellspacing=0 cellpadding=0>;
  <tr>;
    <td>;客戶名稱A</td>;
    <td>;客戶名稱B</td>;
    <td>;客戶名稱C</td>;
    <td>;客戶名稱D</td>;
    <tr>;
    <td>;abc</td>;
    <td>;def</td>;    <td>;111</td>;    <td>;222</td>;  <tr>;
    <td>;ddd</td>;
    <td>;dfdf</td>;
    <td>;ddd</td>;
    <td>;ddd</td>;
</table>;
</div>;
<script language=&quot;javascript&quot;>;
  Spreadsheet1.HTMLData = tablers.innerHTML &#59;
</script>;

亂七8招的,自己也不知道貼了什么東西,呵呵,
希望有人能用的著。

論壇徽章:
0
7 [報告]
發(fā)表于 2002-10-14 17:23 |只看該作者

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷)

謝謝大俠指教,非常經(jīng)典,讓我收益匪淺呀!
我是入門小蝦,所以有個很菜問題請教:2000server+jdk+tomcat+informix7.x
我在配置JDBC時已經(jīng)將ifxjdbc拷貝到D:\tomcat\common\lib下,并且設(shè)置了環(huán)境變量指向
這個目錄,可是用測試程序測試連接數(shù)據(jù)庫時還是出現(xiàn)“Apache Tomcat/4.0.5 - HTTP Status 500 - Internal Server Error”,下面還有很多錯誤提示,請問如何解決?

論壇徽章:
0
8 [報告]
發(fā)表于 2002-10-16 09:52 |只看該作者

java初學(xué)者應(yīng)讀--轉(zhuǎn)載CSDN之 wjmmml (笑著悲傷)

察看你的tomcat的log文件 應(yīng)該會有更多信息提示你的
hahu 該用戶已被刪除
9 [報告]
發(fā)表于 2002-10-24 10:40 |只看該作者
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP