e1059. implementing conditional content on a jsp page.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 22 行

TXT
22
字号
Any non-JSP code in a JSP file is called template text and is automatically written to the output stream. By wrapping template text fragments in scriptlets, it is possible to dynamically choose which fragment to generate. 
These examples generate different template text depending on the value of request parameters: 

    <% if ("someValue".equals(request.getParameter("param1"))) { %>
        Generate this template text if param1 equals someValue
    <% } else { %>
        Otherwise generate this template text
    <% } %>
    
    
    <% switch (Integer.parseInt(request.getParameter("param2"))) {
        case 0: %>
           Generate this template text if param2 equals 0
    <%     break;
        case 1: %>
           Generate this template text if param2 equals 1
    <%     break;
        default: %>
           Generate this template text if param2 equals anything else
    <% } %>

See also e1069 Conditionally Generating Output Using JSTL in a JSP Page. 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?