Java Access Datainsight Demo

Source: Internet
Author: User

Gkycaction.java (Hang Ke forecast)

1  Packagecom.bp.gkyc.action;2 3 Importjava.io.IOException;4 Importjava.util.List;5 ImportJava.util.Map;6 7 Importorg.apache.http.HttpEntity;8 Importorg.apache.http.ParseException;9 ImportOrg.apache.http.client.methods.CloseableHttpResponse;Ten ImportOrg.apache.http.client.methods.HttpPost; One ImportOrg.apache.http.entity.ContentType; A Importorg.apache.http.entity.StringEntity; - Importorg.apache.http.impl.client.CloseableHttpClient; - Importorg.apache.http.impl.client.HttpClients; the Importorg.apache.http.util.EntityUtils; - ImportOrg.springframework.stereotype.Controller; - ImportOrg.springframework.ui.ModelMap; - Importorg.springframework.web.bind.annotation.RequestMapping; + ImportOrg.springframework.web.bind.annotation.RequestMethod; - ImportOrg.springframework.web.bind.annotation.ResponseBody; +  A ImportCom.alibaba.fastjson.JSONObject; at  - @Controller -@RequestMapping ("/BP/GKYC") -  Public classgkycaction { -  - @RequestMapping in      PublicString Index (Modelmap map) { -         return"BP/GKYC/GKYC"; to     } +  - @ResponseBody the@RequestMapping (value = "Gkuser", method =requestmethod.post) *      PublicString Getgkuser () { $String res = "";Panax Notoginseng         Try { -Jsonobject BODY =NewJsonobject (); theString DSL = "es \" stu-model\ "--maxevent=1000 | where Score==-1 | Applymodel \ "Bpneural\", \ "stuscoremodel\"--inputfields=\ "clubtime,schoolabsent,classabsent, Entertainmentinternet\ "--predictfield=\" predictscore\ "| Keep \ "Name\", \ "Predictscore\" | Sort Predictscore "; +Jsonobject params =NewJsonobject (); AParams.put ("Sync",true); theBody.put ("DSL", DSL); +Body.put ("params", params); -String str =body.tojsonstring (); $String url = "http://localhost:9000/explorer/query/"; $Closeablehttpclient client =Httpclients.createdefault (); -HttpPost post =Newhttppost (URL); -             if(!Str.isempty ()) { thePost.setentity (Newstringentity (str, contenttype.application_json)); -             }WuyiCloseablehttpresponse response =Client.execute (POST); thehttpentity entity =response.getentity (); -  Wures =entityutils.tostring (entity); -  About             if(Entity! =NULL) { $ Entityutils.consume (entity); -             } - client.close (); -}Catch(ParseException e) { A             //TODO auto-generated Catch block + e.printstacktrace (); the}Catch(IOException e) { -             //TODO auto-generated Catch block $ e.printstacktrace (); the         } the         returnRes; the     } the  -}

Js

1 Util.ajax ({2Url:contextpath + "/bp/gk/gkuser",//the path to the request background3Success:function(data) {4             varGkxs = "";5              for(vari=1;i<11;i++){6                 if(i==1){7Gkxs + = "<a href=\" #\ "name=\" xslb\ "id=\" xs "+i+" \ "onclick=\" Clickxs ("+i+") \ "class=\" List-group-item active\ "> "+data.content.data[i+1].values[0]+" <span class=\ "badge badge-primary\" > "+i+" </span></a> ";8}Else{9Gkxs + = "<a href=\" #\ "name=\" xslb\ "id=\" xs "+i+" \ "onclick=\" Clickxs ("+i+") \ "class=\" list-group-item\ ">" + data.content.data[i+1].values[0]+ "<span class=\" badge badge-primary\ ">" +i+ "</span></a>";Ten                 } One             } A$ ("#gkxs"). HTML (GKXS); -         } -});

Java Access Datainsight Demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.