Velocity的资源工具与Spring框架的集成

发布于 2024-10-10 03:48:17 字数 535 浏览 0 评论 0原文

嘿伙计们, 我正在尝试将resourceTool集成到spring中。 它工作得很好,只有 1 个问题,默认编码是 ISO-8859-1。 所以..做了一些研究,我想出了 3 种可能的解决方案。

I. 在 web.xml 中添加过滤器: 设置字符编码过滤器 org.springframework.web.filter.CharacterEncodingFilter 编码 UTF-8 强制编码 真的 设置字符编码过滤器 /*

  1. 在视图解析器中添加一行:
  2. 手动更改响应的编码: response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); (设置编码只是确保内容类型也设置编码本身)

但是,一旦我完成其中任何一个,我的所有字符串都会变成乱码,而且无论我更改什么编码它仍然是乱码(只得到如果有的话更糟)。

关于如何解决它有什么想法吗? 有人吗? ^_^

hey guys,
I'm trying to integrate a resourceTool into spring.
it worked just fine,only 1 problem, default encoding was ISO-8859-1.
so..a bit of research and i came up with 3 possible solutions.

I. add a filter in web.xml :

SetCharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8

forceEncoding
true

SetCharacterEncodingFilter
/*

  1. add a line in the viewresolvers:
  2. manually changing the response's encoding:
    response.setContentType("text/html;charset=UTF-8");
    response.setCharacterEncoding("UTF-8");
    (set encoding is just making sure as content type also sets the encoding itself)

HOWEVER, as soon as i've done EITHER of those, all my strings turn to gibrish, also no matter to what encoding i change it remains gibrish( only gets worse if anything).

any ideas on how to solve it?
anyone? ^_^

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲在坟头点根烟 2024-10-17 03:48:17

您可能应该告诉 Velocity 也使用 UTF-8,并带有 input.encoding 和/或 output.encoding 属性。

You should probably tell Velocity to use UTF-8 also, with the input.encoding and/or output.encoding properties.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文