admin管理员组文章数量:1026989
I have jsp page and some set of javascript code written inside the jsp page.
for(i=0;i<10;i++)
{
//some stuff
}
but in the browser its giving error and the rendered code look like
for(i=0;
i<10;
i++ { }
how to stop converting "<" to "<
".
Thanks in advance.
I have jsp page and some set of javascript code written inside the jsp page.
for(i=0;i<10;i++)
{
//some stuff
}
but in the browser its giving error and the rendered code look like
for(i=0;
i<10;
i++ { }
how to stop converting "<" to "<
".
Thanks in advance.
Share Improve this question asked Jan 31, 2011 at 10:14 Ra.Ra. 9654 gold badges18 silver badges30 bronze badges3 Answers
Reset to default 1Is your JS code meant to be executed, or just displayed as it is?
If you have the former situation, is your code inside <script type="text/javascript">...</script>
tags?
If you have the latter situation, then characters such as <
HAVE to be converted to <
, otherwise they would be read as HTML tags by your browser.
JSP does by default not do that. Aren't you actually using JSTL <c:out>
to print JavaScript code? It can namely do that. You could disable that by adding escapeXml="false"
attribute.
Anyway, best would always be to put JS code in its own .js
file which you then include in the head as follows:
<script src="script.js"></script>
Hope this helps....
function toHtml(myString)
{
htmlString = myString.split("<").join("<");
htmlString = htmlString.split(">").join(">");
htmlString = htmlString.split(""").join("\"");
htmlString = htmlString.split("'").join("\'");
return htmlString;
}
Gretting. Víctor
I have jsp page and some set of javascript code written inside the jsp page.
for(i=0;i<10;i++)
{
//some stuff
}
but in the browser its giving error and the rendered code look like
for(i=0;
i<10;
i++ { }
how to stop converting "<" to "<
".
Thanks in advance.
I have jsp page and some set of javascript code written inside the jsp page.
for(i=0;i<10;i++)
{
//some stuff
}
but in the browser its giving error and the rendered code look like
for(i=0;
i<10;
i++ { }
how to stop converting "<" to "<
".
Thanks in advance.
Share Improve this question asked Jan 31, 2011 at 10:14 Ra.Ra. 9654 gold badges18 silver badges30 bronze badges3 Answers
Reset to default 1Is your JS code meant to be executed, or just displayed as it is?
If you have the former situation, is your code inside <script type="text/javascript">...</script>
tags?
If you have the latter situation, then characters such as <
HAVE to be converted to <
, otherwise they would be read as HTML tags by your browser.
JSP does by default not do that. Aren't you actually using JSTL <c:out>
to print JavaScript code? It can namely do that. You could disable that by adding escapeXml="false"
attribute.
Anyway, best would always be to put JS code in its own .js
file which you then include in the head as follows:
<script src="script.js"></script>
Hope this helps....
function toHtml(myString)
{
htmlString = myString.split("<").join("<");
htmlString = htmlString.split(">").join(">");
htmlString = htmlString.split(""").join("\"");
htmlString = htmlString.split("'").join("\'");
return htmlString;
}
Gretting. Víctor
本文标签: javascriptStop converting quotltquot to quotampltquot in jspStack Overflow
版权声明:本文标题:javascript - Stop converting "<" to "&lt;" in jsp - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745660217a2161842.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论