HTML / Spring / JSP de doble escape

This is what gets rendered in the html source:

<li>Confirm Password doesn&amp;#39;t match password./li>

On the browser, this is read as: Confirm Password doesn&#39;t match password.

This is the code that generates this:

<spring:hasBindErrors name="profileAccount">
  <ul class="errorsList">
    <c:forEach items="${errors.allErrors}" var="error">
      <li><spring:message code="${error.code}"
          text="${error.defaultMessage}"
        /></li>
    </c:forEach>
  </ul>
</spring:hasBindErrors>

How can I prevent the double escaping?

Muchas Gracias

preguntado el 09 de marzo de 12 a las 14:03

2 Respuestas

spring:hasBindErrors y spring:message ambos obey the default global HTML escaping setting (either via defaultHtmlEscape as a context param. or via the htmlEscape etiqueta).

El resultado final es que ${error.defaultMessage} will already have been escaped by the time it is passed into <spring:message>. You can work around this by disabling HTML escaping on one (but no the other). Example:

<spring:message htmlEscape="false" code="${error.code}" text="${error.defaultMessage}"/>

Respondido 17 Jul 19, 13:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.