【问题标题】:hide div tag in jsp page在jsp页面中隐藏div标签
【发布时间】:2014-05-08 12:09:26
【问题描述】:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
<script type="text/javascript">
$(document).ready(function()
        {
            if()==null)
            {

            }
        }
);
</script>
</head>

<center>
    <%@ include file="Head.jsp" %>
</center>
<body>
<div id="tempDiv">
    <h1>Message : ${message}</h1>   
    <h1>Author : ${author}</h1>
</div>  
    <a href='<c:url value="/j_spring_security_logout" />' > Logout</a>
    <div align="center">
        <table class="table1">
            <tr>
                <td align="center" width="800" height="400"><font size="10">
                        Welcome </font></td>
            </tr>
        </table>

    </div>
</body>
</html>

$message 值未出现时如何隐藏 div 标签。 我想隐藏我的 div 标签。在jsp页面中。当用户点击主页时。 我在这里尝试了 javascript 代码,但没有得到任何关于如何在 javascript 中使用 jsp 元素的答案。 或在我的情况下对隐藏 div 标签有用的任何代码都建议。谢谢你....

【问题讨论】:

    标签: javascript jsp jsp-tags


    【解决方案1】:

    试试这个

    <c:if test="${empty message}">
    
    </c:if>
    <c:if test="${not empty message}">
    <div id="tempDiv">
        <h1>Message : ${message}</h1>   
        <h1>Author : ${author}</h1>
    </div>  
    </c:if>
    

    您需要检查变量是否为空,并取决于 html 页面上的打印输出...希望它有效

    或者其他方式

    <c:choose>
        <c:when test="${empty message}">
    
        </c:when>
        <c:otherwise>
        <div id="tempDiv">
            <h1>Message : ${message}</h1>   
            <h1>Author : ${author}</h1>
        </div>  
        </c:otherwise>
    </c:choose>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多