Keyword: <C: Choose> label C: Choose label used to select the execution statement
When the result of C: When test is true, the content in the label is executed;
If all C: When test results are false, execute the content in C: otherwise;
The format is as follows:
<C: Choose>
<C: When test = "testcondition">
Content1
</C: When>
<C: When test = "testcondition">
Content2
</C: When>
<C: otherwise>
Content3
</C: otherwise>
</C: Choose>
Testjstlchoose. jsp:
Program code
- <% @ 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> testjstlchoose </title>
- </Head>
- <Body>
- <Form action = "testjstlchoose. jsp" method = "Post">
- Please enter a name: <input type = "text" name = "name"/>
- <Input type = "Submit" value = "Submit"/>
- </Form>
- <C: If test = "$ {! Empty Param. name} ">
- <C: Choose>
- <C: When test = "$ {Param. Name = 'magcies'}">
- Welcome Goodman $ {Param. name}
- </C: When>
- <C: When test = "$ {Param. Name = 'mgc'}">
- Welcome $ {Param. name}
- </C: When>
- <C: otherwise>
- $ {Param. name}
- </C: otherwise>
- </C: Choose>
- </C: If>
- </Body>
- </Html>