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');
}
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) {
//創(chuàng)建一個(gè)新的字符串
StringReader read = new StringReader(xmlDoc);
//創(chuàng)建新的輸入源SAX 解析器將使用 InputSource 對(duì)象來(lái)確定如何讀取 XML 輸入
InputSource source = new InputSource(read);
//創(chuàng)建一個(gè)新的SAXBuilder
SAXBuilder sb = new SAXBuilder();
try {
//通過(guò)輸入源構(gòu)造一個(gè)Document
Document doc = sb.build(source);
//取的根元素
Element root = doc.getRootElement();
System.out.println(root.getName());//輸出根元素的名稱(測(cè)試)
//得到根元素所有子元素的集合
List jiedian = root.getChildren();
//獲得XML中的命名空間(XML中未定義可不寫(xiě))
Namespace ns = root.getNamespace();
Element et = null;
for(int i=0;i<jiedian.size();i++){
et = (Element) jiedian.get(i);//循環(huán)依次得到子元素
/**//*
* 無(wú)命名空間定義時(shí)
* 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 自動(dòng)生成 catch 塊
e.printStackTrace();
} catch (IOException e) {
// TODO 自動(dòng)生成 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號(hào) </users_address>"+
"</row>"+
"<row resultcount=\"1\">"+
"<users_id>1002 </users_id>"+
"<users_name>wangwei </users_name>"+
"<users_group>80 </users_group>"+
"<users_address>1002號(hào) </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>堆存費(fèi)</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>堆存費(fèi)</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);
}
}
eclipse插件(axis2 tool--Code Generator Wizard)實(shí)現(xiàn)Java調(diào)用 asmx 的Web Service
一個(gè)獲得天氣情況及國(guó)家城市的 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方式安裝.即可以通過(guò)自動(dòng)
生成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 后會(huì)自動(dòng)生成兩個(gè)文件:
GlobalWeatherCallbackHandler.java 和 GlobalWeatherStub.java
新建一個(gè)測(cè)試文件GlobalWeatherTest.java.
內(nèi)容如下:
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("=================國(guó)家城市=================");
//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("=================國(guó)家/城市/天氣=================");
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();
}
}
}
運(yùn)行結(jié)果如下:
=================國(guó)家城市=================
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
=================國(guó)家/城市/天氣=================
<?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)==============
用同樣的方法生成代碼有五個(gè):
GlobalWeather.java
GlobalWeatherLocator.java
GlobalWeatherSoap.java
GlobalWeatherSoapProxy.java
GlobalWeatherSoapStub.java
客戶端調(diào)用如下:
GlobalWeatherLocator gwl = new GlobalWeatherLocator();
GlobalWeatherSoapStub binding = (GlobalWeatherSoapStub)gwl.getGlobalWeatherSoap();
System.out.println(">>>"+binding.getCitiesByCountry("Korea"));
System.out.println(binding.getWeather("Seoul", "Korea"));
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);
摘要: Oracle 字符集的查看和修改
一、什么是Oracle字符集
Oracle字符集是一個(gè)字節(jié)數(shù)據(jù)的解釋的符號(hào)集合,有大小之分,有相互的包容關(guān)系。ORACLE 支持國(guó)家語(yǔ)言的體系結(jié)構(gòu)允許你使用本地化語(yǔ)言來(lái)存儲(chǔ),處理,檢索數(shù)據(jù)。它使數(shù)據(jù)庫(kù)工具,錯(cuò)誤消息,排序次序,日期,時(shí)間,貨幣,數(shù)字,和日歷自動(dòng)適應(yīng)本地化語(yǔ)言和平臺(tái)。...
閱讀全文
從結(jié)構(gòu)上看,所有的數(shù)據(jù)(data)最終都可以分解成三種類型:
第一種類型是標(biāo)量(scalar),也就是一個(gè)單獨(dú)的字符串(string)或數(shù)字(numbers),比如"北京"這個(gè)單獨(dú)的詞。
第二種類型是序列(sequence),也就是若干個(gè)相關(guān)的數(shù)據(jù)按照一定順序并列在一起,又叫做數(shù)組(array)或列表(List),比如"北京,上海"。
第三種類型是映射(mapping),也就是一個(gè)名/值對(duì)(Name/value),即數(shù)據(jù)有一個(gè)名稱,還有一個(gè)與之相對(duì)應(yīng)的值,這又稱作散列(hash)或字典(dictionary),比如"首都:北京"。
我恍然大悟,數(shù)據(jù)構(gòu)成的最小單位原來(lái)如此簡(jiǎn)單!難怪在編程語(yǔ)言中,只要有了數(shù)組(array)和對(duì)象(object)就能夠儲(chǔ)存一切數(shù)據(jù)了。
關(guān)于json。
21世紀(jì)初,Douglas Crockford尋找一種簡(jiǎn)便的數(shù)據(jù)交換格式,能夠在服務(wù)器之間交換數(shù)據(jù)。當(dāng)時(shí)通用的數(shù)據(jù)交換語(yǔ)言是XML,但是Douglas Crockford覺(jué)得XML的生成和解析都太麻煩,所以他提出了一種簡(jiǎn)化格式,也就是Json。
Json的規(guī)格非常簡(jiǎn)單,只用一個(gè)頁(yè)面幾百個(gè)字就能說(shuō)清楚,而且Douglas Crockford聲稱這個(gè)規(guī)格永遠(yuǎn)不必升級(jí),因?yàn)樵撘?guī)定的都規(guī)定了。
1) 并列的數(shù)據(jù)之間用逗號(hào)(",")分隔。
2) 映射用冒號(hào)(":")表示。
3) 并列數(shù)據(jù)的集合(數(shù)組)用方括號(hào)("[]")表示。
4) 映射的集合(對(duì)象)用大括號(hào)("{}")表示。
上面四條規(guī)則,就是Json格式的所有內(nèi)容。
比如,下面這句話:
"北京市的面積為16800平方公里,常住人口1600萬(wàn)人。上海市的面積為6400平方公里,常住人口1800萬(wàn)。"
寫(xiě)成json格式就是這樣:
[
{"城市":"北京","面積":16800,"人口":1600},
{"城市":"上海","面積":6400,"人口":1800}
]
如果事先知道數(shù)據(jù)的結(jié)構(gòu),上面的寫(xiě)法還可以進(jìn)一步簡(jiǎn)化:
[
["北京",16800,1600],
["上海",6400,1800]
]
由此可以看到,json非常易學(xué)易用。所以,在短短幾年中,它就取代xml,成為了互聯(lián)網(wǎng)上最受歡迎的數(shù)據(jù)交換格式。
我猜想,Douglas Crockford一定事先就知道,數(shù)據(jù)結(jié)構(gòu)可以簡(jiǎn)化成三種形式,否則怎么可能將json定義得如此精煉呢!
學(xué)習(xí)javascript的時(shí)候,我曾經(jīng)一度搞不清楚"數(shù)組"(array)和"對(duì)象"(object)的根本區(qū)別在哪里,兩者都可以用來(lái)表示數(shù)據(jù)的集合。
比如有一個(gè)數(shù)組a=[1,2,3,4],還有一個(gè)對(duì)象a={0:1,1:2,2:3,3:4},然后你運(yùn)行alert(a[1]),兩種情況下的運(yùn)行結(jié)果是相同的!這就是說(shuō),數(shù)據(jù)集合既可以用數(shù)組表示,也可以用對(duì)象表示,那么我到底該用哪一種呢?
我后來(lái)才知道,數(shù)組表示有序數(shù)據(jù)的集合,而對(duì)象表示無(wú)序數(shù)據(jù)的集合。如果數(shù)據(jù)的順序很重要,就用數(shù)組,否則就用對(duì)象。
當(dāng)然,數(shù)組和對(duì)象的另一個(gè)區(qū)別是,數(shù)組的數(shù)據(jù)沒(méi)有"名稱"(name),對(duì)象的數(shù)據(jù)有"名稱"(name)。
但是問(wèn)題是,很多編程語(yǔ)言中,都有一種叫做"關(guān)聯(lián)數(shù)組"(associative array)的東西。這種數(shù)組中的數(shù)據(jù)是有名稱的。
比如在javascript中,可以這樣定義一個(gè)對(duì)象:
var a={"城市":"北京","面積":16800,"人口":1600};
但是,也可以定義成一個(gè)關(guān)聯(lián)數(shù)組:
a["城市"]="北京";
a["面積"]=16800;
a["人口"]=1600;
這起初也加劇了我對(duì)數(shù)組和對(duì)象的混淆,后來(lái)才明白,在Javascript語(yǔ)言中,關(guān)聯(lián)數(shù)組就是對(duì)象,對(duì)象就是關(guān)聯(lián)數(shù)組。
有個(gè)問(wèn)題,沒(méi)有考慮中文編碼字符,由于遷移的表有幾千萬(wàn)數(shù)據(jù),但是有中文的記錄集很少,問(wèn)我能否找出有中文內(nèi)容的記錄數(shù)。首先我想到的是采用檢測(cè)每個(gè)字節(jié)ASCII的方式,這樣的話需要寫(xiě)一個(gè)自定義函數(shù),然后SQL中調(diào)用得到結(jié)果。但是感覺(jué)這個(gè)方法估計(jì)很耗時(shí),畢竟每個(gè)字符都要比較,所以沒(méi)有去實(shí)現(xiàn)。突然想到Oracle有一個(gè)編碼轉(zhuǎn)換的函數(shù)叫Convert,如果一個(gè)字符串編碼轉(zhuǎn)換前后不一樣就表示字符串里面含有非ASCII字符,這樣就得到結(jié)果。最后寫(xiě)出來(lái)測(cè)試了一下,確實(shí)可行,5500萬(wàn)記錄10秒鐘就掃描結(jié)束。以下是測(cè)試用例:
SQL> select *
2 from (select 'abcd' c1 from dual
3 union all
4 select 'ab測(cè)試cd' c1 from dual)
5 where c1 <> CONVERT(c1, 'US7ASCII', 'ZHS16GBK');
C1
--------
ab測(cè)試cd
CONVERT函數(shù)說(shuō)明:
CONVERT(inputstring,dest_charset,source_charset)
inputstring:要轉(zhuǎn)換的字符串
dest_charset:目標(biāo)字符集
source_charset:原字符集
2、延遲腳本
HTML4.0為<script>標(biāo)簽定義了defer的屬性。這個(gè)屬性的用途是表明腳本在執(zhí)行時(shí)不會(huì)影響頁(yè)面的構(gòu)造。也就是說(shuō),腳本會(huì)延遲到整個(gè)頁(yè)面都解析完畢后在執(zhí)行。因此,在<script>元素中設(shè)置defer屬性(如下面的例子),實(shí)際上與上面介紹的把<script>元素放在頁(yè)面底部的效果是一樣的。
<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>
<!--這里放內(nèi)容-->
</body>
</html>
這個(gè)例子中,雖然我們把<script>元素放在了文檔的<head>元素中,但其中包含的腳本將延遲到瀏覽器遇到</html>標(biāo)簽后在執(zhí)行。
不過(guò),問(wèn)題是并非所有瀏覽器都支持defer屬性,IE和firefox3.0是目前唯一支持defer屬性的主流瀏覽器。其他瀏覽器則會(huì)忽略這個(gè)屬性,不延遲腳本的執(zhí)行
從request獲取各種路徑總結(jié)
request.getRealPath("url"); // 虛擬目錄映射為實(shí)際目錄


request.getRealPath("./"); // 網(wǎng)頁(yè)所在的目錄

request.getRealPath("../"); // 網(wǎng)頁(yè)所在目錄的上一層目錄

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


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

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

以工程名為TEST為例:

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


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


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


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


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

2.在類中取得路徑:

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


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

3.在Servlet中取得路徑:

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


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


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