JSP 将外币显示为垃圾
我试图使用 apache fmt tag-lib 中的 formatnumber 标签在我的 jsp 中显示外币,它显示垃圾字符数据。我可以确认,当我在控制台上打印时,控制器中的“动态货币符号值”显示正确,并且我显式地将响应对象编码设置为 UTF-8,jsp 页面编码和字符集也设置为 UTF-8。设置区域设置不会有帮助,因为交易是以外币进行的,并且任何交易都可以在世界任何地方查看。
似乎 formatnumber tag 有一个错误,但不确定是否有任何替代方案。 mail-archives.apache.org/mod_mbox/tomcat-taglibs-user/200308.mbox/%3C000001c36bc5$4ee81db0$0100a8c0@pentium3%3E 我查了一下欧元和日元。
我粘贴了我的jsp http://pastebin.com/eZAKKeJ9 的部分代码。我尝试打印浏览器以确保传递给标签的内容,因此其垃圾行 545 告诉,而第 564 行告诉与货币一起传递的格式编号。 和处理程序 http://pastebin.com/H21fdbZm 。检查浏览器以确保其默认更改为 UTF-8。任何帮助表示赞赏。 编辑:垃圾邮件不允许我发布超过 2 个链接。
I am trying to display foriegn currencies in my jsp using formatnumber tag from apache fmt tag-lib, it displays junk char data. i can confirm that in controller 'the dynamic currency symbol value' being displayed correctly when I print out on console and I explicitly set response object encoding to UTF-8 and jsp page encoding and charset to UTF-8 as well. Setting the locale wont help as the transaction are in foriegn currencies and any transaction can be viewed on any part of the world.
Seems like there is a bug with formatnumber tag , but not sure about any alternatives for that.
mail-archives.apache.org/mod_mbox/tomcat-taglibs-user/200308.mbox/%3C000001c36bc5$4ee81db0$0100a8c0@pentium3%3E
I checked this EURO and yen .
I pasted the part of code of my jsp http://pastebin.com/eZAKKeJ9. I tried printing out browser to make sure what's being pass to tag, so its junk line 545 tells and line 564 tell the formatnumber being passed with currency.
and handler http://pastebin.com/H21fdbZm . Checked the browser to make sure it had default changed to UTF-8. Any help is appreciated.
edit: spam doesnt allow me to post more than 2 links.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的代码来看:
当 bean 属性实际返回非 UTF-8 字符时,可能会出现此问题。您需要在该角色起源的源中修复它。它是一个Java文件吗?确保文件保存为 UTF-8。它是属性文件吗?确保使用 unicode 转义序列。它是数据库条目吗?确保该表使用 UTF-8。 ETC。
From your code:
This problem can occur when the bean property actually returned a non-UTF-8 character. You need to fix it in the source where this character originated. Is it a Java file? Ensure that file is saved as UTF-8. Is it a properties file? Ensure that you use an unicode escape sequence. Is it a database entry? Ensure that the table uses UTF-8. Etc.