Die Funktion dieses Applets dient hauptsächlich darin, die Informationen von Provinz-, Gemeinde- und Distriktinformationen aus der Datenbank abzurufen und sie mit asynchroner Anfrage in der Dropdown-Liste anzuzeigen:
Der Code ist wie folgt:
Der Code in der Datenbank und einige Konfigurationsdateiinformationen werden weggelassen, hauptsächlich der Code in JavaScript lautet:
$ (document) .ready (function () {$. get ("getProvince.do", Funktion (Ergebnis) {$ ("#showp"). document.getElementByIdx_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x ("show"); show.innerhtml = ""; var province = document.getElementByIdx_x_x_x_x_x_x_x_x_x_x_x ("provinz"). value; if (provinz! ActiveXObject ("microsoft.xmlhttp");} xmlhttp.onReadyStatechange = function () {if (xmlhttp.ReadyState == 4 && xmlhttp.status == 200) {show.innnerhtml = xmlhttp.respontexe; Encodeuricomponent (str); Xmlhttprequest ();} else {xmlhttp = new ActiveXObject ("microsoft.xmlhttp");} xmlhttp.onReadyStatEchange = function () {if (xmlhttp.Readystate == 4 && xmlhttp.status == 200) {{{4 && xmlhttp.status == 200) {{{{4 && xmlhttp.Stp. document.getElementByIdx_x_x_x_x_x_x_x_x_x_x_x ("show2"); show2.innerhtml = xmlhttp.responsetext;}} var ss = Encodeuricomponent (STR); Der Code in der HTML -Seite lautet:
Standort
Der Code in der Aktion ist:
Paket mobi.zhangsheng.jiejia.action; import Java.io.ioxception; import Java.io.printwriter; import Java.util.List; import Javax.annotation org.apache.struts2.servletactactioncontext; import org.springframework.stereotype.controller; import mobi.zhangsheng.jiejia.domain.areas; import mobi.zangsheng.jiejia.service; Klasse Provinceaktion {private int provinceId; privat int Cityid; @ResourcePrivate biplesVice as; @resourcePrivate AgentsService AGS; public int getProvinceId () {return provincId;} public void setprovincid (int provincid) {this.provincid = provincid; setCityId (int CityId) {this.cityId = CityId;} public void getProvince () {list provincelist = as.getareasprvincelist (); ServletActionContext.getRequest (); // resp.setContentType ("xml"); resp. (IoException e) {e.printstacktrace ();}} public void getCity () {list CityList = as.getAreascityList (ProvincID); httpServletResponse resp = ServletActionContext.getResponse (); // resp.setContentType ("xml"); resept.setContentType ("text/html"); resast.setcharactercoding ("utf-8"); try {printwriter out = reat. (IoException e) {e.printstacktrace ();}} public void getArea () {list arealist = as.getAreascityList (CityId); if (arealist.size () == 0) {} else {httpervletRespon ServletActionContext.getResponse (); resp.setContentType ("text/html"); resp.setcharactercoding ("utf-8"); try {printwriter out = resp.getWriter (); out.print (");} catch (ioException e) {E. printactace ();}} {{E. printace ();} {} {{E. printactace ();}}}}} {{{E. printace);Die Hauptfunktionscodes sind alle drauf. Wenn Sie nicht verstehen, wenden Sie sich bitte an QQ: 1037139984. Ich wünsche Ihnen alle gute Entwicklung, lernen Sie zusammen und wachsen Sie zusammen.