本文介绍了如何在JSP中使引号国际化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中我们在JSP中显示来自客户端的报价.引号的实际文本存储在数据库中,并且不包含引号.

I have an application where we are showing quotes from a client in a JSP. The actual text of the quotation is stored in a database and doesn't include the quotation marks.

该JSP当前具有"{$ bean.quote}",我向老板指出,该文件不可国际化.

The JSP currently has "{$bean.quote}" which, I pointed out to my boss, is not internationalizable.

我已批准他对此进行国际化,但不确定使用哪种方法.我的第一个方法是对startQuote和endQuote进行i18n查找并将字符存储在表中.感觉很重.

I've got his approval to internationalize this, but I'm not sure what approach to use. My first one is to do an i18n lookup for startQuote and endQuote and store the character in the table. This feels heavy.

想法?

推荐答案

这是一种实现方法.但是你是对的.如果您在很多地方都这样做,那么阅读和维护就会很尴尬.

That is one way to do it. But you're right; if you're doing it in a lot of places, it's going to be awkward to read and maintain.

HTML为此具有一个特殊元素: q .因此,您可以将其放在您的页面中:

HTML has a special element for this: q. So you can put this in your page:

<q>${bean.quote}</q>

然后,您可以按照引号部分:

You can then perform the internationalization in the CSS, as described in the Quotation marks section of the CSS specification:

q:lang(en) {
    quotes: '\201c' '\201d' "\2018" "\2019"
}
q:lang(no) {
    quotes: "\ab" "\bb" '"' '"'
}

q:before {
    content: open-quote;
}
q:after {
    content: close-quote;
}

这篇关于如何在JSP中使引号国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:53