Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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
Html 如何停止<;br/>;值不为空时执行_Html_Jsp - Fatal编程技术网

Html 如何停止<;br/>;值不为空时执行

Html 如何停止<;br/>;值不为空时执行,html,jsp,Html,Jsp,我有一个表,我在其中打印数据库中的值,如下所示 姓名年龄地址 我的代码如下,它只在值不为空时打印值 <table class="table"> <tr><td class="td_header"><spring:message code="label.test"/></td></tr> <tr><td> <c:if test="${not empty test.name}">

我有一个表,我在其中打印数据库中的值,如下所示

姓名
年龄
地址

我的代码如下,它只在值不为空时打印值

<table class="table">
<tr><td class="td_header"><spring:message code="label.test"/></td></tr>
<tr><td>
    <c:if test="${not empty test.name}">
        <br/>${test.name}
    </c:if>
    <c:if test="${not empty tax.address2}">
        <br/>${tax.address2}
    </c:if>
</td></tr>
</table>


${test.name}
${tax.address2}
然而,我有一个问题,当它是空的中断线仍然得到推杆,我得到这样的输出

姓名
年龄

添加2

如何解决此问题?

尝试使用
s而不是

<table class="table">
    <tr><td class="td_header"><spring:message code="label.test"/></tr>
    <tr>
        <td>
            <div>${test.name}</div>
            <div>${tax.address2}</div>

${test.name}
${tax.address2}

因此,即使打印出一个空的
,它也不会占用空间。这就是
的设计方法<代码>:)

它无法输出结果的源代码。它可以检查结果的源代码。但是,下面使用div的解决方案已经起作用了。@user3520080当然可以。那么请马上接受我的回答,好吗?基本上OP报告了JSP中的一个严重错误,但事实可能并非如此。无论如何,这并不能回答这个问题。@wvdz这只是一种不同的方法。即使是错误的,如果OP正在输出所有内容。或者,我会做一件事,我会编辑答案并以不同的方式更新,这样你就可以删除否决票了?@wvdz你能检查一下答案吗?我同意你改进了它,但问题显然是OP的
标签没有做它应该做的事情。不使用

。您的解决方案可能适用于这个小示例,但是如果我们需要一个更大的html块上的条件呢?伙计们发现了问题所在,DB中的“空白”值中有空格,因此
条件似乎无法正常工作。我刚刚使用了Java-String trim()方法,它现在可以工作了,尽管div解决方案也提供了一个解决方案。