1.%20
%20是网页地址的空格符。html中的空格符是& nbsp;因为地址不能包含空格。它是序列化后的空格符。在url传递参数的时候,一般都会序列化一下,以保证参数的安全。
2.路径获取问题
String path=Parameter.class.getResource("").toString();//这个无法处理里面的空格。 System.out.println(path); //不可以 String path=Parameter.class.getResource("").getPath(); path=URLDecoder.decode(path,"utf-8");
3.其他应用public class Test { public static void main(String[] args) throws Exception { String s = "test"; System.out.println(replaceMethod(s)); } private static String replaceMethod(String s) { StringBuffer buffer=new StringBuffer(); if(s!=null){ for(int i=0;i<s.length();i++){ char ch=s.charAt(i); if(ch==' '){ buffer.append("%20"); }else{ buffer.append(ch); } } } return buffer.toString(); } }