I want stop < being converted to < in Java when I save it as part of a String
I am storing some HTML as a String which I want to output to a JSP.
Is th开发者_开发百科ere a simply utility function that I should use for this, or should I write my own. I could write it easily but I'd rather do it the most common way.
Thanks,
You don't need to do anything special. A simple expression will output the string without escaping: ${str}
It takes extra work to get escaping, such as using the JSTL <c:out/>
tag. You must be doing something like that, either in the JSP, or to the String
before the JSP is rendered.
I think you have to reinvent wheel here again as java does not provide any class which can do this for you. You can encode and decode URL. Other way is to make use of some one's wheel invention like 'apache commons Langs'.
cheers
I'm not sure I completely follow your question. If you just want to print a string without escaping the output, try:
<% out.println(str); %>
精彩评论