http post 方法

          function costPayCheck() {
                   var name = "test"
                   var PARAMS2 = 'EeM1whUd4q4%3d&money=i6hN5C6DIN4%3d&checkcode=nhIAV2UrfsWnq1I38RKp5%2b46w4bxah62p6tSN%2fESqefuOsOG8WoetiUOtz2bp40id93kxCmKe%2bY%2f%2foU%2b8UmIPnvhxn9jGcsgHGKUTJep4N4q3lr1fo%2bZEWZJXRQhhfJ4RNQDb8RgTAU%3d&feeetype=Q1dQXRPDVOc%3d&old_pay_no=String+%e5%bc%95%e7%94%a8%e6%b2%a1%e6%9c%89%e8%ae%be%e7%bd%ae%e4%b8%ba+String+%e7%9a%84%e5%ae%9e%e4%be%8b%e3%80%82%0d%0a%e5%8f%82%e6%95%b0%e5%90%8d%3a+s&old_money=String+%e5%bc%95%e7%94%a8%e6%b2%a1%e6%9c%89%e8%ae%be%e7%bd%ae%e4%b8%ba+String+%e7%9a%84%e5%ae%9e%e4%be%8b%e3%80%82%0d%0a%e5%8f%82%e6%95%b0%e5%90%8d%3a+s';
                  
                   var tempForm = document.createElement("form"); 
                   tempForm.id="tempForm1"; 
                   tempForm.method="post"; 
                   tempForm.action="         tempForm.target=name; 
                   
                    var hideInput = document.createElement("input"); 
                    hideInput.type="hidden"; 
                   hideInput.name= "pay_no"
                   hideInput.value= PARAMS2;
                    tempForm.appendChild(hideInput);  
                    tempForm.attachEvent("onsubmit",function(){ openWindow(name); });
                   document.body.appendChild(tempForm); 
                  
                   tempForm.fireEvent("onsubmit");
                   tempForm.submit();
                  document.body.removeChild(tempForm);
             }
              
                function openWindow(name) 
              { 
                   window.open('about:blank',name,'height=400, width=400, top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes');  
                }

          posted @ 2013-04-09 13:13 youngturk 閱讀(301) | 評論 (0)編輯 收藏

          JAVA解析XML格式字符串

          import java.io.IOException;
          import java.io.StringReader;
          import java.util.List;

          import org.jdom.Document;
          import org.jdom.Element;
          import org.jdom.JDOMException;
          import org.jdom.Namespace;
          import org.jdom.input.SAXBuilder;
          import org.xml.sax.InputSource;

          public class TestXML {
              public List xmlElements(String xmlDoc) {
                  //創建一個新的字符串
                  StringReader read = new StringReader(xmlDoc);
                  //創建新的輸入源SAX 解析器將使用 InputSource 對象來確定如何讀取 XML 輸入
                  InputSource source = new InputSource(read);
                  //創建一個新的SAXBuilder
                  SAXBuilder sb = new SAXBuilder();
                  try {
                      //通過輸入源構造一個Document
                      Document doc = sb.build(source);
                      //取的根元素
                      Element root = doc.getRootElement();
                      System.out.println(root.getName());//輸出根元素的名稱(測試)
                      //得到根元素所有子元素的集合
                      List jiedian = root.getChildren();
                      //獲得XML中的命名空間(XML中未定義可不寫)
                      Namespace ns = root.getNamespace();
                      Element et = null;
                      for(int i=0;i<jiedian.size();i++){
                          et = (Element) jiedian.get(i);//循環依次得到子元素
                          /**//*
                           * 無命名空間定義時
                           * et.getChild("users_id").getText();
                           * et.getChild("users_address",ns).getText()
                           */
                          /*System.out.println(et.getChild("users_id",ns).getText());
                          System.out.println(et.getChild("users_address",ns).getText());*/
                          System.out.println(et.getChild("p_id",ns).getText());
                          System.out.println(et.getChild("ctnno",ns).getText());
                      }
                      /**//*
                       * 如要取<row>下的子元素的名稱
                       */
                      et = (Element) jiedian.get(0);
                      List zjiedian = et.getChildren();
                      for(int j=0;j<zjiedian.size();j++){
                          Element xet = (Element) zjiedian.get(j);
                          System.out.println(xet.getName());
                      }
                  } catch (JDOMException e) {
                      // TODO 自動生成 catch 塊
                      e.printStackTrace();
                  } catch (IOException e) {
                      // TODO 自動生成 catch 塊
                      e.printStackTrace();
                  }
                  return null;
              }
              public static void main(String[] args){
               TestXML doc = new TestXML();
                  String xml = "<?xml version=\"1.0\" encoding=\"gb2312\"?>"+
                  "<Result xmlns=\"           "<row resultcount=\"1\">"+
                        "<users_id>1001     </users_id>"+
                        "<users_name>wangwei   </users_name>"+
                        "<users_group>80        </users_group>"+
                        "<users_address>1001號   </users_address>"+
                     "</row>"+
                     "<row resultcount=\"1\">"+
                        "<users_id>1002     </users_id>"+
                        "<users_name>wangwei   </users_name>"+
                        "<users_group>80        </users_group>"+
                        "<users_address>1002號   </users_address>"+
                     "</row>"+
                  "</Result>";
                  String xml1 = "<?xml version=\"1.0\" encoding=\"UTF-16LE\" standalone=\"no\"?>" +
                    "<d_fsgl_fee_count_for_xml>" +
                    "  <d_fsgl_fee_count_for_xml_row>" +
                    "  <p_id>JD1302130002</p_id>" +
                    "  <ctnno>CXDU1499549</ctnno>" +
                    "  <fee_type>單</fee_type>" +
                    "  <start_time>2013-02-09 00:00:00</start_time>" +
                    "  <end_time>2013-02-13 00:00:00</end_time>" +
                    "  <fee>4</fee>" +
                    "  <fee_count>16</fee_count>" +
                    "  <cpid></cpid>" +
                    "  <fee_name>堆存費</fee_name>" +
                    "  <fee_rate_id></fee_rate_id>" +
                    "  <jffs>1</jffs>" +
                    "  <if_hand>0</if_hand>" +
                    "  <sfid>FDZT1302180104</sfid>" +
                    "  <wt_company>QT</wt_company>" +
                    "  <opid>928</opid>" +
                    "  <cy>D</cy>" +
                    "  <if_bf></if_bf>" +
                    "  <days_count>4</days_count>" +
                    "  <if_collect>1</if_collect>" +
                    "  <if_dd></if_dd>" +
                    "  <dd_fee_name></dd_fee_name>" +
                    "  <spec_sign>五洲代墊</spec_sign>" +
                    " </d_fsgl_fee_count_for_xml_row>" +
                    " <d_fsgl_fee_count_for_xml_row>" +
                    "  <p_id>JD1302130002</p_id>" +
                    "  <ctnno>CXDU1499549</ctnno>" +
                    "  <fee_type>周</fee_type>" +
                    "  <start_time>2013-02-13 00:00:00</start_time>" +
                    "  <end_time>2013-02-20 00:00:00</end_time>" +
                    "  <fee>4</fee>" +
                    "  <fee_count>32</fee_count>" +
                    "  <cpid></cpid>" +
                    "  <fee_name>堆存費</fee_name>" +
                    "  <fee_rate_id>67</fee_rate_id>" +
                    "  <jffs>1</jffs>" +
                    "  <if_hand>0</if_hand>" +
                    "  <sfid>FDZT1302180104</sfid>" +
                    "  <wt_company>QT</wt_company>" +
                    "  <opid>928</opid>" +
                    "  <cy>D</cy>" +
                    "  <if_bf></if_bf>" +
                    "  <days_count>8</days_count>" +
                    "  <if_collect>1</if_collect>" +
                    "  <if_dd></if_dd>" +
                    "  <dd_fee_name></dd_fee_name>" +
                    "  <spec_sign></spec_sign>" +
                    " </d_fsgl_fee_count_for_xml_row>"  +
                    "</d_fsgl_fee_count_for_xml>";
                  doc.xmlElements(xml1);
              }
          }

           

          posted @ 2013-04-08 17:20 youngturk 閱讀(284) | 評論 (0)編輯 收藏

          eclipse插件實現Java調用 asmx 的Web Service

          eclipse插件(axis2 tool--Code Generator Wizard)實現Java調用 asmx 的Web Service

          一個獲得天氣情況及國家城市的 Web Service
          http://www.webservicex.net/globalweather.asmx?WSDL

          AXIS2 下載地址 http://ws.apache.org/axis2/download.cgi
          其eclipse工具 http://ws.apache.org/axis2/tools/index.html
          Code Generator Wizard - Eclipse Plug-in 可以以eclipse中的link方式安裝.即可以通過自動
          生成java service code.

          具體步驟如下:
          在eclipse的java project中 NEW --> Other --> Axis2 Wizards -->Axis2 Code Generator
          NEXT --> 選擇 Generate java source code from a WSDL file
          NEXT --> 在WSDL file location: 中輸入 : http://www.webservicex.net/globalweather.asmx?WSDL
          NEXT --> NEXT --> 選擇好文件生成路徑
          如: E:\eclipseworkspace\axis213\src
          FINISH 后會自動生成兩個文件:
          GlobalWeatherCallbackHandler.java 和 GlobalWeatherStub.java

          新建一個測試文件GlobalWeatherTest.java.
          內容如下:
          package net.webservicex.www;

          import java.io.FileNotFoundException;
          import java.io.IOException;
          import java.io.StringReader;
          import java.rmi.RemoteException;

          import javax.xml.parsers.DocumentBuilder;
          import javax.xml.parsers.DocumentBuilderFactory;
          import javax.xml.parsers.ParserConfigurationException;

          import org.w3c.dom.Document;
          import org.w3c.dom.Element;
          import org.w3c.dom.Node;
          import org.w3c.dom.NodeList;
          import org.xml.sax.InputSource;
          import org.xml.sax.SAXException;

          public class GlobalWeatherTest {
           public static void main(String[] args) throws RemoteException {
            GlobalWeatherStub stub = new GlobalWeatherStub();
            GlobalWeatherStub.GetCitiesByCountry request = new GlobalWeatherStub.GetCitiesByCountry();
            request.setCountryName("Korea");
            GlobalWeatherStub.GetCitiesByCountryResponse response = stub
              .GetCitiesByCountry(request);
            System.out.println("=================國家城市=================");
            //System.out.println(response.getGetCitiesByCountryResult());
            String xml = response.getGetCitiesByCountryResult();
            parseXML(xml);
            
            GlobalWeatherStub.GetWeather weatherRequest = new
            GlobalWeatherStub.GetWeather();
            weatherRequest.setCountryName("Korea");
            weatherRequest.setCityName("Seoul");
            GlobalWeatherStub.GetWeatherResponse weatherResponse =
            stub.GetWeather(weatherRequest);
            System.out.println("=================國家/城市/天氣=================");
            System.out.println(weatherResponse.getGetWeatherResult());
           }

           public static void parseXML(String xml) {
            DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
            try {
             DocumentBuilder dombuilder = domfac.newDocumentBuilder();
             StringReader rd = new StringReader(xml);
             InputSource is = new InputSource(rd);

             Document doc = dombuilder.parse(is);
             Element root = doc.getDocumentElement();
             NodeList citys = root.getChildNodes();

             if (citys != null) {
              for (int i = 0; i < citys.getLength(); i++) {
               Node city = citys.item(i);
               if (city.getNodeType() == Node.ELEMENT_NODE) {
                for (Node node = city.getFirstChild(); node != null; node = node
                  .getNextSibling()) {
                 if (node.getNodeType() == Node.ELEMENT_NODE) {
                  if (node.getNodeName().equals("Country")) {
                   String country = node.getFirstChild()
                     .getNodeValue();
                   System.out.print(country);
                  }
                  if (node.getNodeName().equals("City")) {
                   String cityname = node.getFirstChild()
                     .getNodeValue();
                   System.out.println(" || " + cityname);
                  }
                 }
                }
               }
              }
             }
            } catch (ParserConfigurationException e) {
             e.printStackTrace();
            } catch (FileNotFoundException e) {
             e.printStackTrace();
            } catch (SAXException e) {
             e.printStackTrace();
            } catch (IOException e) {
             e.printStackTrace();
            }
           }
          }


          運行結果如下:

          =================國家城市=================
          Korea, Republic of || Kwangju Ab
          Korea, Republic of || Kunsan Ab
          Korea, Republic of || Yosu Airport
          Korea, Republic of || Chunchon Ab
          Korea, Republic of || Hoengsong Ab
          Korea, Republic of || Kangnung Ab
          Korea, Republic of || Wonju
          Korea, Republic of || Cheju International Airport
          Korea, Republic of || Pusan / Kimhae International Airport
          Korea, Republic of || Mosulpo Ab
          Korea, Republic of || Sach'On Ab
          Korea, Republic of || Ulsan
          Korea, Republic of || Tonghae Radar Site
          Korea, Republic of || Seoul / Yongdungp'O Rokaf Wc
          Korea, Republic of || Pyongtaek Ab
          Korea, Republic of || Seoul
          Korea, Republic of || Seoul E Ab
          Korea, Republic of || Koon-Ni Range
          Korea, Republic of || Osan Ab
          Korea, Republic of || Paengnyongdo Ab
          Korea, Republic of || Yeonpyeungdo
          Korea, Republic of || Seoul / Kimp'O International Airport
          Korea, Republic of || Yeoju Range
          Korea, Republic of || Suwon Ab
          Korea, Republic of || Camp Stanley / H-207
          Korea, Republic of || Yongsan / H-208 Hp
          Korea, Republic of || Andong
          Korea, Republic of || Paekado
          Korea, Republic of || Taejon Kor-Afb
          Korea, Republic of || Songmu Ab
          Korea, Republic of || Taejon
          Korea, Republic of || Pohang Ab
          Korea, Republic of || Jung Won Rok-Ab
          Korea, Republic of || Mangilsan Ab
          Korea, Republic of || Taegu Ab
          Korea, Republic of || Sangju
          Korea, Republic of || Taegu
          Korea, Republic of || Chongju Ab
          Korea, Republic of || Woong Cheon
          Korea, Republic of || Yechon Ab
          Korea, Democratic People's Republic of || Kimchaek
          Korea, Democratic People's Republic of || Pyongyang
          =================國家/城市/天氣=================
          <?xml version="1.0" encoding="utf-16"?>
          <CurrentWeather>
            <Location>Seoul / Kimp'O International Airport, Korea, South (RKSS) 37-33N 126-48E 18M</Location>
            <Time>Oct 24, 2007 - 11:00 AM EDT / 2007.10.24 1500 UTC</Time>
            <Wind> from the NNW (330 degrees) at 2 MPH (2 KT) (direction variable):0</Wind>
            <Visibility> less than 1 mile:0</Visibility>
            <SkyConditions> partly cloudy</SkyConditions>
            <Temperature> 48 F (9 C)</Temperature>
            <DewPoint> 48 F (9 C)</DewPoint>
            <RelativeHumidity> 100%</RelativeHumidity>
            <Pressure> 30.24 in. Hg (1024 hPa)</Pressure>
            <Status>Success</Status>
          </CurrentWeather>

          WSDL

          =============最新的axis2-eclipse-codegen-wizard-1.4 用法(20080806)==============

          用同樣的方法生成代碼有五個:
          GlobalWeather.java
          GlobalWeatherLocator.java
          GlobalWeatherSoap.java
          GlobalWeatherSoapProxy.java
          GlobalWeatherSoapStub.java

          客戶端調用如下:
          GlobalWeatherLocator gwl = new GlobalWeatherLocator();
          GlobalWeatherSoapStub binding = (GlobalWeatherSoapStub)gwl.getGlobalWeatherSoap();
          System.out.println(">>>"+binding.getCitiesByCountry("Korea"));
          System.out.println(binding.getWeather("Seoul", "Korea"));

          posted @ 2013-04-06 10:37 youngturk 閱讀(3070) | 評論 (1)編輯 收藏

          clone復制對象

          public  Object cloneObject(Object obj) throws Exception{
            ByteArrayOutputStream  byteOut = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(byteOut);
            out.writeObject(obj);
            ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
            ObjectInputStream in =new ObjectInputStream(byteIn);
            return in.readObject();
            }
          淺克隆:List billBoxListClone = (List)BeanUtils.cloneBean(billBoxList);

          posted @ 2013-03-31 22:42 youngturk 閱讀(237) | 評論 (0)編輯 收藏

          oracle字符集設置

               摘要: Oracle 字符集的查看和修改 一、什么是Oracle字符集        Oracle字符集是一個字節數據的解釋的符號集合,有大小之分,有相互的包容關系。ORACLE 支持國家語言的體系結構允許你使用本地化語言來存儲,處理,檢索數據。它使數據庫工具,錯誤消息,排序次序,日期,時間,貨幣,數字,和日歷自動適應本地化語言和平臺。...  閱讀全文

          posted @ 2013-03-30 10:35 youngturk 閱讀(344) | 評論 (0)編輯 收藏

          Apache axis2 + Eclipse 開發 WebService

          http://blog.csdn.net/xiaochunyong/article/details/7764683
          http://wenku.baidu.com/view/b3c7f14033687e21af45a98a.html###

          posted @ 2013-03-21 22:16 youngturk 閱讀(335) | 評論 (0)編輯 收藏

          js數據結構(轉)

          從結構上看,所有的數據(data)最終都可以分解成三種類型

          第一種類型是標量(scalar),也就是一個單獨的字符串(string)或數字(numbers),比如"北京"這個單獨的詞。

          第二種類型是序列(sequence),也就是若干個相關的數據按照一定順序并列在一起,又叫做數組(array)或列表(List),比如"北京,上海"。

          第三種類型是映射(mapping),也就是一個名/值對(Name/value),即數據有一個名稱,還有一個與之相對應的值,這又稱作散列(hash)或字典(dictionary),比如"首都:北京"。

          我恍然大悟,數據構成的最小單位原來如此簡單!難怪在編程語言中,只要有了數組(array)和對象(object)就能夠儲存一切數據了。

           

          關于json

          21世紀初,Douglas Crockford尋找一種簡便的數據交換格式,能夠在服務器之間交換數據。當時通用的數據交換語言是XML,但是Douglas Crockford覺得XML的生成和解析都太麻煩,所以他提出了一種簡化格式,也就是Json。

          Json的規格非常簡單,只用一個頁面幾百個字就能說清楚,而且Douglas Crockford聲稱這個規格永遠不必升級,因為該規定的都規定了。

          1) 并列的數據之間用逗號(",")分隔。

          2) 映射用冒號(":")表示。

          3) 并列數據的集合(數組)用方括號("[]")表示。

          4) 映射的集合(對象)用大括號("{}")表示。

          上面四條規則,就是Json格式的所有內容。

          比如,下面這句話:

          "北京市的面積為16800平方公里,常住人口1600萬人。上海市的面積為6400平方公里,常住人口1800萬。"

          寫成json格式就是這樣:

          [
            {"城市":"北京","面積":16800,"人口":1600},
            {"城市":"上海","面積":6400,"人口":1800}
          ]

          如果事先知道數據的結構,上面的寫法還可以進一步簡化:

          [
            ["北京",16800,1600],
            ["上海",6400,1800]
          ]

          由此可以看到,json非常易學易用。所以,在短短幾年中,它就取代xml,成為了互聯網上最受歡迎的數據交換格式。

          我猜想,Douglas Crockford一定事先就知道,數據結構可以簡化成三種形式,否則怎么可能將json定義得如此精煉呢!

           

          學習javascript的時候,我曾經一度搞不清楚"數組"(array)和"對象"(object)的根本區別在哪里,兩者都可以用來表示數據的集合。

          比如有一個數組a=[1,2,3,4],還有一個對象a={0:1,1:2,2:3,3:4},然后你運行alert(a[1]),兩種情況下的運行結果是相同的!這就是說,數據集合既可以用數組表示,也可以用對象表示,那么我到底該用哪一種呢?

          我后來才知道,數組表示有序數據的集合,而對象表示無序數據的集合。如果數據的順序很重要,就用數組,否則就用對象。

           

          當然,數組和對象的另一個區別是,數組的數據沒有"名稱"(name),對象的數據有"名稱"(name)。

          但是問題是,很多編程語言中,都有一種叫做"關聯數組"(associative array)的東西。這種數組中的數據是有名稱的。

          比如在javascript中,可以這樣定義一個對象:

          var a={"城市":"北京","面積":16800,"人口":1600};

          但是,也可以定義成一個關聯數組:

          a["城市"]="北京";
          a["面積"]=16800;
          a["人口"]=1600;

          這起初也加劇了我對數組和對象的混淆,后來才明白,在Javascript語言中,關聯數組就是對象,對象就是關聯數組。

          posted @ 2013-02-28 10:44 youngturk 閱讀(254) | 評論 (0)編輯 收藏

          Oracle中如何用SQL檢測字段是否包括中文字符

          有個問題,沒有考慮中文編碼字符,由于遷移的表有幾千萬數據,但是有中文的記錄集很少,問我能否找出有中文內容的記錄數。首先我想到的是采用檢測每個字節ASCII的方式,這樣的話需要寫一個自定義函數,然后SQL中調用得到結果。但是感覺這個方法估計很耗時,畢竟每個字符都要比較,所以沒有去實現。突然想到Oracle有一個編碼轉換的函數叫Convert,如果一個字符串編碼轉換前后不一樣就表示字符串里面含有非ASCII字符,這樣就得到結果。最后寫出來測試了一下,確實可行,5500萬記錄10秒鐘就掃描結束。以下是測試用例:

          SQL> select *
            2    from (select 'abcd' c1 from dual
            3          union all
            4          select 'ab測試cd' c1 from dual)
            5   where c1 <> CONVERT(c1, 'US7ASCII', 'ZHS16GBK');
           
          C1
          --------
          ab測試cd

          CONVERT函數說明:

          CONVERT(inputstring,dest_charset,source_charset)

          inputstring:要轉換的字符串

          dest_charset:目標字符集

          source_charset:原字符集

          posted @ 2013-02-06 16:02 youngturk 閱讀(641) | 評論 (0)編輯 收藏

          javascrip與頁面執行順序

          2、延遲腳本
          HTML4.0為<script>標簽定義了defer的屬性。這個屬性的用途是表明腳本在執行時不會影響頁面的構造。也就是說,腳本會延遲到整個頁面都解析完畢后在執行。因此,在<script>元素中設置defer屬性(如下面的例子),實際上與上面介紹的把<script>元素放在頁面底部的效果是一樣的。
          <html>
          <head>
            <title> New Document </title>
            <script type="text/javascript" defer="defer" src="example1.js"></script>
            <script type="text/javascript" defer="defer" src="example2.js"></script>
          </head>
          <body>
            <!--這里放內容-->
          </body>
          </html>
          這個例子中,雖然我們把<script>元素放在了文檔的<head>元素中,但其中包含的腳本將延遲到瀏覽器遇到</html>標簽后在執行。
          不過,問題是并非所有瀏覽器都支持defer屬性,IE和firefox3.0是目前唯一支持defer屬性的主流瀏覽器。其他瀏覽器則會忽略這個屬性,不延遲腳本的執行

          posted @ 2013-02-06 15:57 youngturk 閱讀(422) | 評論 (0)編輯 收藏

          從request獲取各種路徑總結 request.getRealPath("url"); // 虛擬目錄映射為實際目錄 request.getRealPat

          從request獲取各種路徑總結 
          request.getRealPath(
          "url"); // 虛擬目錄映射為實際目錄 


          request.getRealPath(
          "./");    // 網頁所在的目錄 

          request.getRealPath(
          "../"); // 網頁所在目錄的上一層目錄 

          request.getContextPath();    
          // 應用的web目錄的名稱 


          如http:
          //localhost:7001/bookStore/ 
          /bookStore/ => [contextPath] (request.getContextPath()) 

          獲取Web項目的全路徑 
          String strDirPath 
          = request.getSession().getServletContext().getRealPath("/"); 

          以工程名為TEST為例: 

          (
          1)得到包含工程名的當前頁面全路徑:request.getRequestURI() 
          結果:
          /TEST/test.jsp 


          (
          2)得到工程名:request.getContextPath() 
          結果:
          /TEST 


          (
          3)得到當前頁面所在目錄下全名稱:request.getServletPath() 
          結果:如果頁面在jsp目錄下 
          /TEST/jsp/test.jsp 


          (
          4)得到頁面所在服務器的全路徑:application.getRealPath("頁面.jsp"
          結果:D:\resin\webapps\TEST\test.jsp 


          (
          5)得到頁面所在服務器的絕對路徑:absPath=new java.io.File(application.getRealPath(request.getRequestURI())).getParent(); 
          結果:D:\resin\webapps\TEST 

          2.在類中取得路徑: 

          (
          1)類的絕對路徑:Class.class.getClass().getResource("/").getPath() 
          結果:
          /D:/TEST/WebRoot/WEB-INF/classes/pack/ 


          (
          2)得到工程的路徑:System.getProperty("user.dir"
          結果:D:\TEST 

          3.在Servlet中取得路徑: 

          (
          1)得到工程目錄:request.getSession().getServletContext().getRealPath("") 參數可具體到包名。 
          結果:E:\Tomcat\webapps\TEST 


          (
          2)得到IE地址欄地址:request.getRequestURL() 
          結果:http:
          //localhost:8080/TEST/test 


          (
          3)得到相對地址:request.getRequestURI() 
          結果:
          /TEST/test 

          posted @ 2013-01-23 09:01 youngturk 閱讀(9035) | 評論 (0)編輯 收藏

          僅列出標題
          共33頁: First 上一頁 3 4 5 6 7 8 9 10 11 下一頁 Last 
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導航

          統計

          公告

          this year :
          1 jQuery
          2 freemarker
          3 框架結構
          4 口語英語

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          EJB學習

          Flex學習

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 图木舒克市| 井冈山市| 弋阳县| 阜新市| 扬州市| 静安区| 金乡县| 霍林郭勒市| 长顺县| 手游| 望江县| 兴宁市| 普兰县| 井陉县| 武强县| 通州市| 睢宁县| 卓尼县| 保靖县| 泗洪县| 维西| 九龙坡区| 双峰县| 皮山县| 邵阳县| 乌拉特中旗| 五家渠市| 大足县| 扎鲁特旗| 巴青县| 怀柔区| 慈溪市| 沂水县| 普格县| 土默特左旗| 新野县| 炎陵县| 监利县| 河南省| 宁阳县| 常州市|