As long as there is no conflict (for example, ID cannot), I wrote an example of using page parameters to control the internal element ID and load ourselves on each other. This is a JSP page with the following code:
Copy Code code 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" >
<base href= "<%=basePath%>" >
<title> User Login </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 are 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>
<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>
After running, as shown in the figure, you can always point to:
However, if you only take a part of the page, for example, change the button's click Code to:
Copy Code code as follows:
$ ("#d <%= I%>"). Load ("<%=basepath%>login.action input", {i:<%=i+1%>});
So, the load is just a button, not the entire page. As shown in figure: