javascript 如何使用 c:out 在 JSTL 中不转义字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12456027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to not escape chars in JSTL using c:out
提问by Medioman92
i'm using JSTL <c:out>
in my project to support javascript code, i have a string that comes from the servlet like this "2\'000;11\'222;10\'333"
with javascript i'd like to split it to obtain separated values like 2'000;11'222;10'333
....but when i use the <c:out>
tag this "\'"
becames "\'"
messing up the split function....
我<c:out>
在我的项目中使用 JSTL来支持 javascript 代码,我有一个来自 servlet 的字符串"2\'000;11\'222;10\'333"
和 javascript 我想将它拆分以获得分隔值,例如2'000;11'222;10'333
....但是当我使用<c:out>
标签时,这"\'"
变成了"\'"
搞乱拆分功能....
is there a way to tell JSTL not escape chars ?
有没有办法告诉 JSTL 不要转义字符?
stringaCompleta += 'Gennaio;<c:out value="${valori.value}" />';
回答by JB Nizet
Simply don't use the c:out
tag at all:
根本不使用c:out
标签:
stringaCompleta += 'Gennaio;${valori.value}';
Or use it with escapeXml
set to false (but it's needlessly complex):
或者将它escapeXml
设置为 false(但它不必要地复杂):
stringaCompleta += 'Gennaio;<c:out value="${valori.value}" escapeXml="false" />';
The documentationwould have told you.
文档会告诉你。