Escaping JavaScript strings in Java
•
Java
I need to turn it into a string in Java:
<script type="text/javascript">document.write("<img src=\"UpArrow.png\" /> \"); </script>
Can I help you? I've been trying, and in the end
return "<script type=\"text/javascript\">document.write(\"<img src=\"UpArrow.png\" /> \"); </script>";
Which doesn't work because I need to be in uparrow Double escape quotes before and after PNG Because it needs to be escaped in JavaScript, not in Java
Solution
Apache commons has a method in stringescapeutils: escapejavascript method
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码