zoukankan      html  css  js  c++  java
  • 控制标签(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>
  • 相关阅读:
    几大NB IT公司的Orgnizational Chart
    [Buzz.Today]2012.01.19
    ASP.NET常用的三十三种实用代码
    asp.net UrlRewrite 技术的实现
    AJAX 中,让 UpdateProgress 中的内容显示在页面正中央
    AJAX中关于多个UpdatePanel 的 UpdateProgress 的使用方法
    谈谈 Cookie 存取和IE页面缓存的问题
    一个非常实用的 div+css 实现的导航条
    常用 css 示例
    AJAX 带有 取消功能的 UpdateProgress
  • 原文地址:https://www.cnblogs.com/Nickzerui/p/4619674.html
Copyright © 2011-2022 走看看