I'm working in JSP, and I'm still fairly new at this. I need to change single aposthropy into '
or '
, and double aposthropy into "
or "
using StringEscapeUtils.escapeHtml. It compiled successfully. But it didn't work.
Here's my exact testing code.
<%= StringEscapeUtils.escapeHtml("cool 4' product") %>
In view page source, the result is:
cool 4' product
not
cool 4' product.
What's wrong? And how can I fixed it? Thanks.
Use:
StringEscapeUtils.escapeHtml("I'm coder")
Escapes the characters in a String using HTML entities.
For example:
"bread" & "butter"
Becomes:
"bread" & "butter".