Mr_Tao 发表于 2014-2-27 08:47:47

ResourceUtil.java 工具类路径 URI编码问题

   获取路径方法中用:
String path = Thread.currentThread().getContextClassLoader().getResource("").toString();

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAr0AAAB8CAIAAADrbZ+3AAAan0lEQVR4nO2dP27jOhfFvZbs4CFeRZZgIJU3MCsw0kzpYhoD07mOuwFcTWG4fkgxgCvjCwJMMzCQBwSpptNX2BLv5T2kKEu2LOn8IOC9USj+E00eXlK8o4wQQgghJI1R2xkghBBCSGegbiCEEEJIKtQNhBBCCEmFuoEQQgghqVA3EEIIISQV6gZCCCGEpELdQAghhJBUqBsIIYQQkgp1AyGEEEJSoW4ghBBCSCpt64a35eT+frJ8azkbknaz9Lac3N/Ptu0k3lPelhNXpVUreDu7v7+1JkoIIe3RtG7AvfLbcnJ/xP9T84P0dpYaYSBknSy5gsqibmfpA1WbumH9czR6nu/1zf2/49H30fGa/k/f+bluKOX9/HlUpGLzUJbP/fw5mBn7Oo8vKa2O35YTagZCCBFcRzeU/alJauuGWknD+KrohjaxuuEoEY5yQRMbqqsjY1tPyxRJBd0QaHTbWaJy2M5o/SGEEEmabjjOupYzNZOWXXIxBB9vLvNpt+xy/S48ZIQQc/Z4j72d3evJvbwhjMvSCHC6VxrynCyhuamfUP74djZZbvNY/dRlGtuZqE4XuypTVP2sp9/BVH79U9/533Qkg30fz//LouLA/5M0S4hBXaY+XQdvqtgKWQDijOVzOvUTCpsLUkUsdQMhhGjSdUM+nhU9blg3+CFFJHCdwhsn04wAoYDRCNQwEFunOCtLeemBePDLLePUf/YCi5nx23JyekQYNkpsGeuf+Xj833x8GmXlfB0P2MXT0++j8b9w0SAiKdbT3EQBFz7QTd/eYBJ1caIYTssc0/95j9e2fnGZghBCPCroBjdVPg55EXuDFxJEAmM2j5TmCZgAUAxq1l/8MVE3VF7OkNopjwHohsCgZXWDFDrH/6+nG7QF4ntTukFFe3wK7oRAN/X+BncfxInyGZIdsWG/1JKQvJZBCCFD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LjhvGWQQghZAj0UDdIbTCe75VdQSoDa28I6wY/zuO9Y9gys4U8wlf4xbJqIOYU0vy//WfZHeh0Wt0MLHPA3FE3EELIIOmjbvBm/75t4Szd4MWJQ2KArd/zOp3LCuRlpr5u8FPxb5fohov4tSKEENJRBqIb4Ljeqm4I7zTQ58Y3Z29QN6WHceoGQgghqQxANxwNDmALgg1cSAC5NnEB3SD9EkGcsHBjvFkZgMO8p0dKdIOOM/64jmo7owNeQggZIEPQDbkMsJsYiyWMfNwvAk7n8/EFdYNeqpCDuFlTeHNbKpd5THoXoxi9XazAXKGyZOIsfVxHhdZUCCGE9J6e6QZyNaBvXkIIIT2HuoFURu/AIIQQMiCoGwghhBCSCnUDIYQQQlKhbiCEEEJIKtQNhBBCCEmFuoEQQgghqaTqBm6hJ4QQQkgVewO/2CeEEEKGTaV1CuhRkRBCCCFDgbqBEEIIIalU1g30SEAIIYQMlsrfUxivjIQQQggZCrQ3EEIIISQV7m8ghBBCSCrUDYQQQghJpZJu2M64tYEQQggZMDwvkhBCCCGp0D8FIYQQQlKhbiCEEEJIKtQNhBBCCEmFuoEQQgghqVA3EEIIISQV6gZCCCGEpPJ/9WPqiKhVtOEAAAAASUVORK5CYII=此方法获取的路径会被URI编码,一般情况下不会出问题,但是如果项目路径中有空格、#等符号时,特殊符号会别URI,
exp. 空格 = %20 ,

解决方法:http://dev.yesky.com/85/3001085.shtml

页: [1]
查看完整版本: ResourceUtil.java 工具类路径 URI编码问题