流程控制标签

来源:互联网 发布:财经日历软件 编辑:程序博客网 时间:2024/05/17 09:35

在JSTL中包含<c:if>、<c:choose>、<c:when>、<c:otherwise>4种流程控制标签。

1、<c:if>

<c:if var="result" test="${empty param.username}"><form name="form1" method="post" action="">用户名: <input name="username" type="text" id="username" /> <br> <br><input type="submit" name="Submit" value="登录" /></form></c:if><c:if test="${!result}">[${param.username}]欢迎访问我公司网站!</c:if>

2、<c:choose>、<c:when>、<c:otherwise>

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!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=UTF-8"><title>起始页</title></head><body><c:choose><c:when test="${empty param.username}"><form name="form1" method="post" action="">用户名: <input name="username" type="text" id="username" /> <br> <br><input type="submit" value="登录" name="Submit" /></form></c:when><c:otherwise>        [${param.username}]欢迎访问我公司网站!        </c:otherwise></c:choose></body></html>


0 0
原创粉丝点击