這種行爲是故意的嗎?Java URI類:構造函數確定查詢是否被編碼?
//create the same URI using two different constructors
URI foo = null, bar = null;
try {
//constructor: URI(uri string)
foo = new URI("http://localhost/index.php?token=4%2F4EzdsSBg_4vX6D5pzvdsMLDoyItB");
} catch (URISyntaxException e) {}
try {
//constructor: URI(scheme, authority, path, query, fragment)
bar = new URI("http", "localhost", "/index.php", "token=4%2F4EzdsSBg_4vX6D5pzvdsMLDoyItB", null);
} catch (URISyntaxException e) {}
//the output:
//foo.getQuery() = token=4/4EzdsSBg_4vX6D5pzvdsMLDoyItB
//bar.getQuery() = token=4%2F4EzdsSBg_4vX6D5pzvdsMLDoyItB
URI(string uri)構造函數似乎是解碼URI的查詢部分。我認爲查詢部分應該被編碼?爲什麼其他構造函數不能解碼查詢部分?
請問你能改正你的格式,讓你的文章更具可讀性嗎? – Thomas 2011-04-29 06:36:19