首页 > 技术文章 > JSP如何选择性的显示页面元素

cbiwei 2016-12-24 16:35 原文

使用c标签或者s标签的 if.

(1)c标签.比如: <c:if test="${ex==1}">男</c:if>  
(2)s标签.比如  <s:if test="#request.remark"><img src="${userImg}" /></s:if><s:else><img src="222.jpg" /></s:else> 
当为true时候,内容显示.
使用c标签和s标签,之前,要先在页面上进行引用.引用代码:


<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

 

注意:test条件中,引号中不能有多余的空格,否则判断无效。

 

推荐阅读