A Brief Analysis of the Problem of Value Transfer Between JSP Pages
- 2021-10-11 19:18:42
- OfStack
This paper analyzes the problem of value transfer between JSP pages with examples. Share it for your reference, as follows:
The simplest of them is < a > The href in the tag has passed the value,
Write in a. jsp:
<a href="b.jsp?name1= Value "></a>
Then receive in b. jsp:
<%
String name2 = new String(request.getParameter("name1").getBytes("ISO-8859-1"),"GBK");
request.setAttribute("name3",name2);
%>
<input id="id1" value="${name3}"/>
This method is relatively simple, but I also found a problem, for example, can not load dynamically, it is when the page is loaded, the value is also attached, for example,
I have one here < select > Label, which is dynamically cascaded with 1 provinces and cities, then I want to take it at this time < select > The values inside can no longer be passed by href, because I chose < select > The value in it is after the page is loaded, which is what individuals do.
<script>
var href = "b.jsp?sd=";
var getV = function(){
var add = $("#ad").val();
href = href + add;
}
var h1 = function(){
window.location = href;
}
</script>
<select id="ad" onChange="getV()"></select>
<a id="h" href="#" onClick="hl()" ></a>
I hope this article is helpful to everyone's JSP programming.