不使用Restful框架,Spring MVC等方式开发一个Restful API.
client code:
private static void doPut(String url) throws IOException {
HttpPut httpPut = new HttpPut(url);
List<NameValuePair> parameters = new ArrayList<>();
parameters.add(new BasicNameValuePair("code", "c1"));
parameters.add(new BasicNameValuePair("id", "1"));
httpPut.setEntity(new UrlEncodedFormEntity(parameters, StandardCharsets.UTF_8));
HttpResponse httpResponse = HttpClients.createDefault().execute(httpPut);
int status = httpResponse.getStatusLine().getStatusCode();