Html jsp:element创建<;img></img>;要素
在试图清理一些相当粗糙的代码时,我以这种方式重写了一些东西:Html jsp:element创建<;img></img>;要素,html,jsp,jstl,Html,Jsp,Jstl,在试图清理一些相当粗糙的代码时,我以这种方式重写了一些东西: <jsp:element name="img"> <jsp:attribute name="src"> <c:url value="${akamai}/images/prdLargerImage.gif"/> </jsp:attribute> <jsp:attribute name="alt">Zoom Image</jsp:at
<jsp:element name="img">
<jsp:attribute name="src">
<c:url value="${akamai}/images/prdLargerImage.gif"/>
</jsp:attribute>
<jsp:attribute name="alt">Zoom Image</jsp:attribute>
</jsp:element>
变焦图像
…但惊讶地发现JSP生成了以下代码:
<img src="/images/prdLargerImage.gif" alt="Zoom Image">
</img>
有没有办法强制它生成
?您可以通过web.xml
中的以下条目将容器配置为删除空白:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
*.jsp
真的
没有什么能阻止你用一个悬挂的
而不是一个短标签您可以通过
web.xml
中的以下条目将容器配置为删除空白:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
*.jsp
真的
没有什么能阻止你用一个悬挂的
而不是一个短标签
我应该指出,我还尝试了上面的代码,手动删除了所有匿名空白。结果是
我应该指出,我还尝试了上面的代码,手动删除了所有匿名空白。结果是
在我可以信任akamai
包含XML/URL安全值的所有情况下,这肯定是一个干净的解决方案(如果我在JSP 2.0上就好了)。同时,看起来我必须编写格式不正确的XML JSP,或者使用open/closeimg
标记。
没有对其值进行XML/URL编码。它只对任何嵌套
的值进行URL编码。在我可以信任akamai
包含XML/URL安全值的所有情况下,这肯定是一个干净的解决方案(如果我使用的是JSP 2.0)。同时,看起来我必须编写格式不正确的XML JSP,或者使用open/closeimg
标记。
没有对其值进行XML/URL编码。它只对任何嵌套的
的值进行URL编码。