URL 工具类 URLUtil

com.justep.util.URLUtil 用于编码和解码的工具类,要求开发者在后端使用该类对 url 进行编码和解码,以解决前后端编码规范不一致产生的问题

decodeURIComponent

decodeURIComponent(String s)

功能:对 url 进行解码
说明:使用了 UTF-8 格式进行解码
参数:
    s:需要解码的目标 url
返回:
    类型:String
示例:
    String url="http://entrylz2-vip.trunk2.xcaas.com:8800/oauthtt/main/test";
    String enUrl=URLUtil.encodeURIComponent(url);//http%3A%2F%2Fentrylz2-vip.trunk2.xcaas.com%3A8800%2Foauthtt%2Fmain%2Ftest

encodeURIComponent

encodeURIComponent(String s)

功能:对 url 进行编码
说明:使用了 UTF-8 格式进行编码
参数:
    s:需要编码的目标 url
返回:
    类型:String
示例:
    String url="http://entrylz2-vip.trunk2.xcaas.com:8800/oauthtt/main/test";
    String enUrl=URLUtil.encodeURIComponent(url);//http%3A%2F%2Fentrylz2-vip.trunk2.xcaas.com%3A8800%2Foauthtt%2Fmain%2Ftest
    String deUrl=URLUtil.decodeURIComponent(enUrl);//http://entrylz2-vip.trunk2.xcaas.com:8800/oauthtt/main/test

results matching ""

    No results matching ""