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)建一個新的字符串
StringReader read = new StringReader(xmlDoc);
//創(chuàng)建新的輸入源SAX 解析器將使用 InputSource 對象來確定如何讀取 XML 輸入
InputSource source = new InputSource(read);
//創(chuàng)建一個新的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);//循環(huán)依次得到子元素
/**//*
* 無命名空間定義時
* 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);
}
}
eclipse插件(axis2 tool--Code Generator Wizard)實現(xiàn)Java調(diào)用 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.
內(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("=================國家城市=================");
//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
客戶端調(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字符集是一個字節(jié)數(shù)據(jù)的解釋的符號集合,有大小之分,有相互的包容關系。ORACLE 支持國家語言的體系結構允許你使用本地化語言來存儲,處理,檢索數(shù)據(jù)。它使數(shù)據(jù)庫工具,錯誤消息,排序次序,日期,時間,貨幣,數(shù)字,和日歷自動適應本地化語言和平臺。...
閱讀全文
從結構上看,所有的數(shù)據(jù)(data)最終都可以分解成三種類型:
第一種類型是標量(scalar),也就是一個單獨的字符串(string)或數(shù)字(numbers),比如"北京"這個單獨的詞。
第二種類型是序列(sequence),也就是若干個相關的數(shù)據(jù)按照一定順序并列在一起,又叫做數(shù)組(array)或列表(List),比如"北京,上海"。
第三種類型是映射(mapping),也就是一個名/值對(Name/value),即數(shù)據(jù)有一個名稱,還有一個與之相對應的值,這又稱作散列(hash)或字典(dictionary),比如"首都:北京"。
我恍然大悟,數(shù)據(jù)構成的最小單位原來如此簡單!難怪在編程語言中,只要有了數(shù)組(array)和對象(object)就能夠儲存一切數(shù)據(jù)了。
關于json。
21世紀初,Douglas Crockford尋找一種簡便的數(shù)據(jù)交換格式,能夠在服務器之間交換數(shù)據(jù)。當時通用的數(shù)據(jù)交換語言是XML,但是Douglas Crockford覺得XML的生成和解析都太麻煩,所以他提出了一種簡化格式,也就是Json。
Json的規(guī)格非常簡單,只用一個頁面幾百個字就能說清楚,而且Douglas Crockford聲稱這個規(guī)格永遠不必升級,因為該規(guī)定的都規(guī)定了。
1) 并列的數(shù)據(jù)之間用逗號(",")分隔。
2) 映射用冒號(":")表示。
3) 并列數(shù)據(jù)的集合(數(shù)組)用方括號("[]")表示。
4) 映射的集合(對象)用大括號("{}")表示。
上面四條規(guī)則,就是Json格式的所有內(nèi)容。
比如,下面這句話:
"北京市的面積為16800平方公里,常住人口1600萬人。上海市的面積為6400平方公里,常住人口1800萬。"
寫成json格式就是這樣:
[
{"城市":"北京","面積":16800,"人口":1600},
{"城市":"上海","面積":6400,"人口":1800}
]
如果事先知道數(shù)據(jù)的結構,上面的寫法還可以進一步簡化:
[
["北京",16800,1600],
["上海",6400,1800]
]
由此可以看到,json非常易學易用。所以,在短短幾年中,它就取代xml,成為了互聯(lián)網(wǎng)上最受歡迎的數(shù)據(jù)交換格式。
我猜想,Douglas Crockford一定事先就知道,數(shù)據(jù)結構可以簡化成三種形式,否則怎么可能將json定義得如此精煉呢!
學習javascript的時候,我曾經(jīng)一度搞不清楚"數(shù)組"(array)和"對象"(object)的根本區(qū)別在哪里,兩者都可以用來表示數(shù)據(jù)的集合。
比如有一個數(shù)組a=[1,2,3,4],還有一個對象a={0:1,1:2,2:3,3:4},然后你運行alert(a[1]),兩種情況下的運行結果是相同的!這就是說,數(shù)據(jù)集合既可以用數(shù)組表示,也可以用對象表示,那么我到底該用哪一種呢?
我后來才知道,數(shù)組表示有序數(shù)據(jù)的集合,而對象表示無序數(shù)據(jù)的集合。如果數(shù)據(jù)的順序很重要,就用數(shù)組,否則就用對象。
當然,數(shù)組和對象的另一個區(qū)別是,數(shù)組的數(shù)據(jù)沒有"名稱"(name),對象的數(shù)據(jù)有"名稱"(name)。
但是問題是,很多編程語言中,都有一種叫做"關聯(lián)數(shù)組"(associative array)的東西。這種數(shù)組中的數(shù)據(jù)是有名稱的。
比如在javascript中,可以這樣定義一個對象:
var a={"城市":"北京","面積":16800,"人口":1600};
但是,也可以定義成一個關聯(lián)數(shù)組:
a["城市"]="北京";
a["面積"]=16800;
a["人口"]=1600;
這起初也加劇了我對數(shù)組和對象的混淆,后來才明白,在Javascript語言中,關聯(lián)數(shù)組就是對象,對象就是關聯(lián)數(shù)組。
有個問題,沒有考慮中文編碼字符,由于遷移的表有幾千萬數(shù)據(jù),但是有中文的記錄集很少,問我能否找出有中文內(nèi)容的記錄數(shù)。首先我想到的是采用檢測每個字節(jié)ASCII的方式,這樣的話需要寫一個自定義函數(shù),然后SQL中調(diào)用得到結果。但是感覺這個方法估計很耗時,畢竟每個字符都要比較,所以沒有去實現(xiàn)。突然想到Oracle有一個編碼轉換的函數(shù)叫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函數(shù)說明:
CONVERT(inputstring,dest_charset,source_charset)
inputstring:要轉換的字符串
dest_charset:目標字符集
source_charset:原字符集
2、延遲腳本
HTML4.0為<script>標簽定義了defer的屬性。這個屬性的用途是表明腳本在執(zhí)行時不會影響頁面的構造。也就是說,腳本會延遲到整個頁面都解析完畢后在執(zhí)行。因此,在<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>
<!--這里放內(nèi)容-->
</body>
</html>
這個例子中,雖然我們把<script>元素放在了文檔的<head>元素中,但其中包含的腳本將延遲到瀏覽器遇到</html>標簽后在執(zhí)行。
不過,問題是并非所有瀏覽器都支持defer屬性,IE和firefox3.0是目前唯一支持defer屬性的主流瀏覽器。其他瀏覽器則會忽略這個屬性,不延遲腳本的執(zhí)行
從request獲取各種路徑總結
request.getRealPath("url"); // 虛擬目錄映射為實際目錄


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

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

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("") 參數(shù)可具體到包名。
結果:E:\Tomcat\webapps\TEST


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


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