I want to use the page c: foreach to iterate over the json array, to achieve the function of dynamic refresh screen,
But the problem is even in js (ajax) will be returned to the data into an array Object, in the JSP page is unable to access to the array, using JSP expressions or el expression cannot in js array in the field, if I want to directly to splice HTML code in the js code, and more complex,,,, this problem bothering me for a long time, hope to get a great god answers,
Originally the JSP is used to display data as servlet storing List
<% List
The JSP code:
<% @ page language="Java" contentType="text/HTML. Charset=utf-8 "
PageEncoding="utf-8" % & gt;
<% @ page import="Java. Util. *, com. CXSW. ZMS. Po. *" % & gt;
<% @ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % & gt;
<% PageProductModel allphone=(PageProductModel) request. GetAttribute (" allphone "); %>
<% List
<script SRC="https://bbs.csdn.net/topics/js/jquery.js" & gt; </script>
<script SRC="https://bbs.csdn.net/topics/js/xcConfirm.js" type="text/javascript" charset="utf-8" & gt; </script>
var a="";
Var obj=document. GetElementsByName (" brand ");
for(var i=0; I
A +=obj [I] value + ", ";
}
}
//alert (a.s ubstring (0, a. ength - 1));
//the window. The location="${pageContext. Request. ContextPath}/GetProductsByBrandServlet? Pro_kind=cell phone & amp; Brand="+ a.s ubstring (0, a. ength - 1);
var xmlHttp;
XmlHttp=null;
If (window. The XMLHttpRequest) {
xmlHttp=new XMLHttpRequest();
} the if (xmlHttp!=null) {
XmlHttp. Onreadystatechange=state_Change;
XmlHttp. Open (" GET ", "${pageContext. Request. ContextPath}/GetProductsByBrandServlet? Pro_kind=cell phone & amp; Brand="+ a.s ubstring (0, a. ength - 1), false);
xmlHttp.send(null);
}
The function state_Change ()
{
If (xmlHttp. ReadyState==4)
{//4="the loaded"
If (xmlHttp. Status==200)
{//200="OK"
Var x=xmlHttp. The responseText;
Var obj=eval (x);
Alert (obj);
//how to use the data returned in the JSP page obj
}
The else
{
Alert (" Problem retrieving data: "+ XMLHTTP. StatusText);
}
}
</script>
The function filter () {
var a="";
Var obj=document. GetElementsByName (" brand ");
for(var i=0; I
A +=obj [I] value + ", ";
}
}
//alert (a.s ubstring (0, a. ength - 1));
Window. The location="${pageContext. Request. ContextPath}/GetProductsByBrandServlet? Pro_kind=cell phone & amp; Brand="+ a.s ubstring (0, a. ength - 1);
}
</script> -->
If (& lt; % %=allphone & gt;==null) {
Window. The location="${pageContext. Request. ContextPath}/PhonePageServlet";
};
}
</script>
<body>
//here using ajax data returned by the