Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html jsp:element创建<;img></img>;要素_Html_Jsp_Jstl - Fatal编程技术网

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/close
img
标记。
没有对其
值进行XML/URL编码。它只对任何嵌套
值进行URL编码。在我可以信任
akamai
包含XML/URL安全值的所有情况下,这肯定是一个干净的解决方案(如果我使用的是JSP 2.0)。同时,看起来我必须编写格式不正确的XML JSP,或者使用open/close
img
标记。
没有对其
值进行XML/URL编码。它只对任何嵌套的
值进行URL编码。