Examination_system/Examination_system-1/.svn/pristine/20/200325f6b27c5ffea4fcbfeab78...

43 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-10-30 13:10:40 +08:00
package com.bonus.question.controller;
import java.util.HashMap;
import java.util.Map;
import com.gexin.fastjson.JSON;
import com.gexin.fastjson.JSONObject;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
public class LbsgetGrade {
public static final String url = "http://112.31.106.185:9722/Sim";
public static String appadd(String str,String str2) {
String baseinfo="";
try {
if(!str.equals("") && !str2.equals("")) {
HttpRequest request = HttpUtil.createPost(url);
Map<String ,String> map=new HashMap<String ,String>();
map.put("str1", str);
map.put("str2", str2);
String param= JSON.toJSONString(map);
System.out.println(param);
String dataStr = request.body(param).execute().body();
JSONObject jsStr = JSONObject.parseObject(dataStr);
baseinfo = jsStr.get("Similarity").toString();
}else {
baseinfo="2";
}
} catch (Exception e) {
e.printStackTrace();
}
return baseinfo;
}
public static void main(String[] args) {
String param1="中国我爱你";
String param2="3这";
String appadd = appadd(param1,param2);
System.out.println("获取的参数"+appadd);
}
}