- JSP page
When using the jstl's Expression Language, the request parameters are made available in the implicit objectParam
. This example demonstrates how to include the value of a request parameter from the query string or posted data in the generated output:
When jstl is used, the URL request parameters are placed in the hidden object.ParamThe following example shows how to obtain request parameters from a URL.
<% -- Declare the core library -- %> <% @ taglib uri = "/WEB-INF/TLD/C. TLD "prefix =" C "%> <C: Choose> <C: When test =" $ {emptyParam. Name} "> Please enter your name. </C: When> <C: otherwise> Hello <B> <C: Out value ="$ {Param. name}"/> </B>! </C: otherwise> </C: Choose>
When the following URL is used to request a page
Http://hostname.com/mywebapp/mypage.jsp? Name = John + Smith
Page display:
Hello <B> john smith </B>!
For Request ParametersNameUse<C: Out value = "$ {Param. name}"/>Output
In addition, if the request parameters contain spaces, separate them with +.
- Use of the sturts framework
When using action-type forwarding, you can call request. getparameter ("name") in the action class to obtain the request parameters,
When the request is forwarded to the target page, the request parameter still exists in the request, so the target page can still retrieve the request parameter through the param object;
This method also applies when forwarding directly to the page only through forwardaction.