As long as there is no conflict (for example, the id cannot be the same), I wrote an example to use the page parameters to control the internal element IDs and load myself to each other. This is a jsp page. The Code is as follows:
Copy codeThe Code is as follows:
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" %>
<%
String path = request. getContextPath ();
String basePath = request. getScheme () + "://"
+ Request. getServerName () + ":" + request. getServerPort ()
+ Path + "/";
Int I = Integer. parseInt (request. getParameter ("I") = null? "0": request. getParameter ("I "));
%>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Base href = "<% = basePath %>">
<Title> User Logon </title>
<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "This is my page">
<Script type = "text/javascript" src = "<% = path %>/Scripts/jquery-1.5.1.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# H <% = I %>"). click (function (){
$ ("# D <% = I %> "). load ("<% = basePath %> index. jsp ", {I: <% = I + 1%> });
});
});
</Script>
</Head>
<Body>
This is index. jsp? I = <% = I %>
<Input type = "button" value = "get <% = I + 1%>" id = "h <% = I %>">
<Br>
<Div id = "d <% = I %>" style = "border: 1px; border-style: solid; margin: 5px;"> load index. jsp? I = <% = I + 1%> here! </Div>
</Body>
</Html>
After running, you can continue:
However, if you only take a part of the page, for example, change the code for clicking the button:
Copy codeThe Code is as follows:
$ ("# D <% = I %> "). load ("<% = basePath %> Login. action input ", {I: <% = I + 1%> });
Then, the load is just a button, not the whole page.