问题
I have a photo selection model, but for some reason whenever I call the path of the images, the space in the path is converted to it's HTML code and I'm not sure why. Do any of you have any ideas? Thanks for any help you can spare.
回答1:
It's url encoded. I dont know the java library to un-encode but I'm sure it's out there and fairly easy to use.
edit - http://download.oracle.com/javase/1.4.2/docs/api/java/net/URLDecoder.html
this maybe?
回答2:
The specification for URLs (RFC 1738, Dec. '94) says:
Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.
And we have:
- Space = decimal code point 32 in the ISO-Latin set.
- 32 decimal = 20 in hexadecimal
- The URL encoded representation will be "%20"
来源:https://stackoverflow.com/questions/5474345/in-java-my-file-paths-with-included-spaces-show-up-as-20-and-im-not-sure-why