<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # JSP `forward`動作標簽 > 原文: [https://beginnersbook.com/2013/11/jsp-forward-action-tag/](https://beginnersbook.com/2013/11/jsp-forward-action-tag/) JSP `forward`動作標簽用于將請求轉發到另一個資源(它可以是 JSP,靜態頁面,如 HTML 或 Servlet)。可以使用或不使用參數轉發請求。在本教程中,我們將看到`<jsp:forward>`的示例。動作標簽。 **語法:** 1)帶參數的轉發。 ```html <jsp:forward page="display.jsp"> <jsp:param ... /> <jsp:param ... /> <jsp:param ... /> ... <jsp:param ... /> </jsp:forward> ``` 2)沒有參數的轉發。 ```html <jsp:forward page="Relative_URL_of_Page" /> ``` `Relative_URL_of_Page`:如果頁面位于主頁面所在的同一目錄中,則使用頁面名稱本身,就像我在下面的示例中所做的那樣。 ### JSP 轉發示例 1 - 不傳遞參數 在這個例子中,我們有兩個 JSP 頁面 - `index.jsp`和`display.jsp`。我們使用了`index.jsp`中的動作標簽`<jsp:forward>`,用于將請求轉發給`display.jsp`。這里我們在使用動作標簽時沒有傳遞任何參數。在下一個示例中,我們還將參數傳遞給另一個資源。 `index.jsp` ```html <html> <head> <title>JSP forward action tag example</title> </head> <body> <p align="center">My main JSP page</p> <jsp:forward page="display.jsp" /> </body> </html> ``` `display.jsp` ```html <html> <head> <title>Display Page</title> </head> <body> Hello this is a display.jsp Page </body> </html> ``` **輸出:** 下面是上面代碼的輸出。它基本上是`display.jsp`的內容,它清楚地表明`index.jsp`在將請求轉發到`display.jsp`頁面時沒有顯示。 ![JSPForward-Output](https://img.kancloud.cn/71/99/71993aaae5f2b4b0cf47a6ea46b3257e_503x263.jpg) ### JSP 轉發示例 2 - 帶參數 這里我們傳遞參數和前向請求。對于傳遞參數,我們使用<jsp:param>`動作標簽。在這個例子中,我們傳遞了 4 個參數并轉發,后來我們在轉發的頁面上顯示它們。為了獲取`display.jsp`頁面上的參數,我們使用[`request`隱式對象](https://beginnersbook.com/2013/11/jsp-implicit-object-request-with-examples/)的`getParameter`方法。 `index.jsp` ```html <html> <head> <title>JSP forward example with parameters</title> </head> <body> <jsp:forward page="display.jsp"> <jsp:param name="name" value="Chaitanya" /> <jsp:param name="site" value="BeginnersBook.com" /> <jsp:param name="tutorialname" value="jsp forward action" /> <jsp:param name="reqcamefrom" value="index.jsp" /> </jsp:forward> </body> </html> ``` `display.jsp` ```html <html> <head> <title>Display Page</title> </head> <body> <h2>Hello this is a display.jsp Page</h2> My name is: <%=request.getParameter("name") %><br> Website: <%=request.getParameter("site") %><br> Topic: <%=request.getParameter("tutorialname") %><br> Forward Request came from the page: <%=request.getParameter("reqcamefrom") %> </body> </html> ``` **輸出:** 上面的代碼直接顯示了`display.jsp`頁面,它顯示了從`index.jsp`頁面傳遞的參數。 ![forward-param-output](https://img.kancloud.cn/d6/4b/d64b5722736862fbad81b0d1ef530189_503x263.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看