When a url comes in, such as http: // localhost: 8080/pro/demo/hello. jsp? Name = john. On the hello. jsp page, we can get the name value as follows:
Copy codeThe Code is as follows:
<%
String path = request. getContextPath ();
String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/";
String name = request. getParameter ("name"); // obtain the parameter using the request
%>
It is displayed in <body> hello: <% = name %> </body>.
You can also use $ {} directly in the body, because when using jstl, url request parameters are placed in the hidden object param. So you can write it like this:
Copy codeThe Code is as follows:
<Body> hello :$ {param. name} </body>
Based on this logic, you can use the same method when using jquery, for example:
$ (Function (){
Alert ($ {param. name });
});