【自用】爬虫配置XML时拼接URL中文转Unicode问题(例如北京转成%u5317%u4EAC)

<var-def name="regionUnicode">
    <while condition="true" index="s" max-loops="${region.toString().length()}" empty="false">
        <template>
           ${"%u"+java.lang.Integer.toHexString(region.toString().charAt(s.toInt()))}
        </template>
    </while>
</var-def>

这样转换成的每个字符后面会有空行,用的时候需要regionUnicode.toString().replaceAll("\s","")替换一下空行

原文地址:https://www.cnblogs.com/misul/p/3781835.html