使用jsp:include和json-taglib的HTML输出 [英] HTML output with jsp:include and json-taglib
问题描述
我使用jsp:include内部的 json-taglib 的json:property元素。与此相关的问题是,来自包含的JSP页面的所有HTML元素在某些时候被剥离并且只保留纯文本。我已经删除了所有换行符,所以结果必须是有效的JSON数据。
如何获得由json-taglib返回的完整HTML?
以下是显示情况的摘录。
<%@ page language =java% >
<%@ page pageEncoding =UTF-8%>
<%@ page contentType =text / html; charset = UTF-8%>
<%@ taglib uri =http://www.atg.com/taglibs/jsonprefix =json%>
< json:object>
< json:property name =idvalue =$ {element.id}/>
< json:属性名称=htmlescapeXml =false>
< jsp:include page =/ templates / generate-component.jsp>
< jsp:param name =element_idvalue =$ {element.id}/>
< / jsp:include>
< / json:property>
< / json:object>
一个解决方案是将jsp:include包装在< c:out>
标记和(mis)使用body-as-default-value,如下所示:
< c:out value =$ {null}>
< jsp:include ...>
< jsp:param ... />
< / jsp:include>
< / c:out>
然而,在包含的JSP本身使用jsp:include的情况下,这不起作用。 / p>
I'm using jsp:include inside json-taglib's json:property element. The problem with this is that all HTML elements from included JSP page gets stripped at some point and only plain text remains. I have already stripped all newlines so the result shoud be valid JSON data.
How do I get full HTML returned by json-taglib?
Below is a snippet demonstrating the situation.
<%@ page language="java" %>
<%@ page pageEncoding="UTF-8" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://www.atg.com/taglibs/json" prefix="json" %>
<json:object>
<json:property name="id" value="${element.id}" />
<json:property name="html" escapeXml="false">
<jsp:include page="/templates/generate-component.jsp">
<jsp:param name="element_id" value="${element.id}" />
</jsp:include>
</json:property>
</json:object>
One solution is to wrap the jsp:include in <c:out>
tag and (mis)use the body-as-default-value, like so:
<c:out value="${null}">
<jsp:include ...>
<jsp:param ... />
</jsp:include>
</c:out>
However, this won't work in a situation where the included JSP itself uses jsp:include.
这篇关于使用jsp:include和json-taglib的HTML输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!