• 控制标签(if、elseif、else)


     1 <%@ page language="java" contentType="text/html; charset=UTF-8"%>
     2 <%@ taglib uri="/struts-tags" prefix="struts"%>
     3 <%@ taglib uri="/struts-tags" prefix="s"%>
     4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     5 <html>
     6 <head>
     7 <title>My JSP 'index.jsp' starting page</title>
     8 <meta http-equiv="pragma" content="no-cache">
     9 <meta http-equiv="cache-control" content="no-cache">
    10 <meta http-equiv="expires" content="0">
    11 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    12 <meta http-equiv="description" content="This is my page">
    13 <!--
    14     <link rel="stylesheet" type="text/css" href="styles.css">
    15     -->
    16     
    17 <struts:head theme="ajax" />
    18 
    19 <style type="text/css">
    20 body,td {
    21     font-size: 12px;
    22 }
    23 </style>
    24 </head>
    25 
    26 <body>
    27 
    28 <struts:fielderror></struts:fielderror>
    29 
    30 <struts:form action="if">    <!-- 提交给"if.action" -->
    31     <struts:textfield name="name" label="姓名: "></struts:textfield>
    32     <struts:submit value=" 提交 "></struts:submit>
    33 </struts:form>
    34 
    35 <!-- 利用 request 参数判断 -->
    36 <struts:if test="#parameters.name[0] == 'Kurt'">        <!-- 如果参数为Kurt -->
    37     Hello, Kurt. 
    38 </struts:if>
    39 <struts:elseif test="#parameters.name[0] == 'Matt'">    <!-- 如果参数为Matt -->
    40     Hello, Matt. 
    41 </struts:elseif>
    42 <struts:else>                                           <!-- 否则 -->
    43     Hello, Other Buddies. 
    44 </struts:else>
    45 
    46 <br/>
    47 
    48 <!-- 利用 action 属性判断 -->
    49 <struts:if test="name == 'Kurt'">
    50     Hello, Kurt. 
    51 </struts:if>
    52 <struts:elseif test="name == 'Matt'">
    53     Hello, Matt. 
    54 </struts:elseif>
    55 <struts:else>
    56     Hello, Other Buddies. 
    57 </struts:else>
    58 
    59 <br/>
    60 
    61 <!-- 
    62 <struts:set name="key" value="%{'You are welcome. '}"></struts:set>
    63 <struts:property value="#key" /> <br/>
    64 <struts:property value="%{#key}" /> <br/>
    65 <struts:property value="key" /> <br/>
    66  -->
    67 
    68 
    69 </body>
    70 </html>
  • 相关阅读:
    二叉查找树详解
    探索推荐引擎内部的秘密
    个性化推荐漫谈
    网站的可扩展架构
    网站伸缩性架构--数据存储服务器集群的伸缩性设计
    SQL Server 分组后取Top N
    SQL SERVER 查询特定的前几条数据
    数据库的事务处理必须满足ACID原则,ACID分别是指什么
    String在JAVA里是固定长度的吗?为什么可用“+”连接
    怎样取得数组对象和arralist 的长度
  • 原文地址:https://www.cnblogs.com/Nickzerui/p/4619674.html
Copyright © 2020-2023  润新知