requesttags.jsp

来自「部门结构树」· JSP 代码 · 共 80 行

JSP
80
字号
<%@ taglib uri="/WEB-INF/requesttags.tld" prefix="request" %>

<html>
<head>
    <title>The Request Tags</title>
    <link rel="stylesheet" href="/prizetagsdemo/stylesheet.css" type="text/css">
</head>
<body>
<h2>The Request Tags</h2>
<p>
    The request tags makes it easy for an included page to<br/>
    write the URI, URL or web app context path to its output stream. That way<br/>
    you don't have to hardcode the URL's of pages that link back to themselves.<br/>
    JSP pages containing either tabbed panes or trees usually link back to themselves.<br/>
    The request tags gives you the following advantages:<br/>
</p>

<ol>
    <li>If you include a JSP page inside another JSP page, and the included JSP<br/>
        page needs to link back to the including page, this is easily done<br/>
        using the request tags.<br/><br/>
    </li>

    <li>
        If you forward to, or include, a JSP page from a Struts action <br/>
        or Spring controller, and the JSP needs to link back to that<br/>
        controller, then URI / URL is automatically pointing back<br/>
        to the Struts action or Spring controller. Not to the JSP.    <br/>
        This is usually handy when using Tree Tag or Tabbed Pane Tag       <br/>
        with Struts or Spring.<br/><br/>
    </li>


    <li>
        If you include the same JSP page in many different other JSP pages  <br/>
        (or Struts Actions or Spring Controllers), then the link back to         <br/>
        the including page or action will always point correctly to the url of the    <br/>
        including action or page.
    </li>

</ol>


<table cellspacing="0" cellpadding="5" style="border: 1px solid black;">
    <tr><td style="border-bottom: 1px solid black;"><b>Tag</b></td>
        <td style="border-bottom: 1px solid black;"><b>Tag Code</b></td>
        <td style="border-bottom: 1px solid black;"><b>Tag Output</b></td></tr>

    <tr><td><b>Request URI</b></td>
        <td>&lt;request:requestUri/&gt;</td>
        <td><b><request:requestUri/></b></td>
    </tr>

    <tr><td><b>Request URL</b></td>
        <td>&lt;request:requestUrl/&gt;</td>
        <td><b><request:requestUrl/></b></td>
    </tr>

    <tr><td><b>Web App Context Path</b></td>
        <td>&lt;request:webAppContextPath/&gt;</td>
        <td><b><request:webAppContextPath/></b></td>
    </tr>

    <tr><td valign="top"><b>Parameter String</b></td>
        <td valign="top">&lt;request:parameterString/&gt;</td>
        <td><b><request:parameterString/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(suffix=false)<br/>
               <request:parameterString suffix="true"/> &nbsp;&nbsp;&nbsp;(suffix=true)</b></td>
    </tr>
</table>

<p>
    Try seeing the effect of the parameterString tag...<br/>
    ...<a href="<request:requestUri/>?param1=123&otherParam=abc">with request parameters</a><br/>
    ...<a href="<request:requestUri/>">without request parameters</a><br/>

</p>


</body>
</html>

⌨️ 快捷键说明

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