One, JavaScript cross-domain access
1. Set the Document.domain value of the access page and the page being visited.
2, use the IFRAME to connect two domains of the page.
II. Ajax cross-domain access
1, using the script tag to achieve
The implementation example has two pages a.b.com/source.jsp, c.d.com/target.jsp, where the target.jsp page is accessed in the Source.jsp page
The code is as follows:
source.jsp
<mce:script type= "Text/javascript" id= "Geturl" "src=" "></mce:script> <mce:script type=" text/ JavaScript "><!--function Fungetotherdomain () {var obj = document.getElementById (" Geturl "); obj.src=" http:// C.d.com/target.jsp "; alert (obj.readystate); alert (XML); if (obj.readystate== "loaded") {alert (jsonobject.name); alert (jsonobject.address);}} --></mce:script>
target.jsp
<% @page import= "net.sf.json.*,java.util.*"%> <% map map = new Linkedhashmap (); Map.put ("name", "AAAA"); Map.put ("Address", "bbbb"); Jsonobject jsonobject = jsonobject.fromobject (map); Out.println ("var jsonobject=" +jsonobject); %>
2. Web Proxy method
Use HttpClient to get page information.
3, the way of the IFRAME