撇号的速度模板问题

发布于 2024-12-20 18:26:04 字数 536 浏览 4 评论 0原文

我正在使用 Velocity 模板,当我使用带撇号的变量时,即:

$用户的

其中“user”是变量名,我得到翻译后的变量值,但撇号变成了一堆问号。例如,如果“user”的值为“Mary Ann”,我会得到:

玛丽·安???

如何“转义”撇号,以便 Velocity mergeTemplate 方法不会产生此输出?顺便说一句,我发送到该方法的编码是 iso-8859-1

Velocity.mergeTemplate(模板,TEMPLATE_ENCODING,上下文,string_writer);

虽然我们没有 Velocity 属性文件,但据我了解,这是默认的 Velocity 编码。

任何反馈将不胜感激。

更新:我可以在 HTML 模板中使用编码 amp#39; 但在文本模板中仍然遇到相同的问题

I am using a Velocity template, and when I use a variable with an apostrophe, i.e.:


$user's

where "user" is the variable name, I get the value for the variable translated, but the apostrophe turns into a bunch of question marks. For instance, if the value for "user" was "Mary Ann," I'd get this:


Mary Ann????s

How can I "escape" the apostrophe so that the Velocity mergeTemplate method will not produce this output? BTW, the encoding that I'm sending to that method is iso-8859-1:


Velocity.mergeTemplate(template, TEMPLATE_ENCODING, context, string_writer);

Although we don't have a Velocity properties file, it's my understanding that this is the default Velocity encoding.

Any feedback would be greatly appreciated.

UPDATE: I can use the encoding amp#39; in the HTML template but I still have the same issue in the text template

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

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

发布评论

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

评论(1

撩起发的微风 2024-12-27 18:26:04

如果此模板在 HTML 上下文中使用,您可以使用

If this template used in context of HTML you can use

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