Applets是否有'事实上'的REST客户端?我需要将由Jackson映射为JSON的POJO发送到Spring MVC控制器。显而易见的选择是Spring Android,因为它有RestTemplate
功能的简化版本,但它显然也有一些特定的功能来确定运行哪个Android版本。
有没有简单的方法来实现这个目标?
我尝试使用HTTPUrlConnection
“手动”执行此操作,但我从未在控制器中看到请求:
URL url = new URL("http", getDomain(), 8080, getBaseUrl()+"save");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Cookie", "JSESSIONID=" + getSessionId());
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestMethod("POST");
connection.connect();
OutputStream out = connection.getOutputStream();
mapper.writeValue(out, state);
out.flush();
out.close();
connection.disconnect();