Greetings,
I am trying to work out the best way to remove double quotes at the presentation / JSP layer, when returning requests as JSON via AJAX, my framework is Struts 1.1.
I have thought of the following:
- Use a static function in the jsp page, escaping quotes.
Not got this working yet but... Euuu.
- When returning the List object from the Logic layer (in the Action layer), loop through the items returned, escaping the various properties of the entity. Yuck.
- Create special methods in the entity, such as 'getDescriptionEscaped' that will do this for me. OMG!
Architecturally, what's the best way to do this?
Have some code:
page.jsp
<%@ page contentType="text/html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page import="Net2U.Nucleo.Utilidades.Autocompletar" %>
{"ucdtPadre":
[
<logic:notEmpty name="lstEntidades" scope="request">
<c:forEach var="Entidad" items="${lstEntidades}" varStatus="status">
{
"codigo": "<c:out value="${Entidad.codigoUCDT}"/>" ,
"descripcion": "<c:out value="${Entidad.descripcionUCDT}" escapeXml="false"/>"
<% //=Autocompletar.magicQuotes(<c:out value="${Entidad.descripcionUCDT}"/>) %>
} <c:if test="${!status.last}">,</c:if>
</c:forEach>
</logic:notEmpty>
]
}
Thanks in advance.