且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

URL解码Java中的日语字符等

更新时间:2023-02-23 12:01:50

不是的那些 URL编码.看起来像%E3%82%B5%E3%83%9C%E3%83%86%E3%83%B3.这些是十进制HTML/XML实体.要转义HTML/XML实体,请使用 Apache Commons Lang

Those are not URL encodings. It would have looked like %E3%82%B5%E3%83%9C%E3%83%86%E3%83%B3. Those are decimal HTML/XML entities. To unescape HTML/XML entities, use Apache Commons Lang StringEscapeUtils.

更新:当响应编码不是UTF-8时,您将得到问号.如果您使用的是JSP,只需将以下行添加到页面顶部:

Update as per the comments: you will get question marks when the response encoding is not UTF-8. If you're using JSP, just add the following line to top of the page:

<%@ page pageEncoding="UTF-8" %>

有关更多中途解决方案的详细信息,请参见本文.我宁愿一味地使用UTF8,也不愿意使用regexp,因为regexp并不会让您为统治世界做好准备.

See for more detail the solutions about halfway this article. I would prefer using-UTF8-all-the-way above fiddling with regexps since regexps doesn't prepare you for world domination.