我从 jsp 调用本地 servlet,servlet 只返回一个 json 字符串:
URL url = new URL("http://myapp.appspot.com/myservlet");
URLConnection conn = url.openConnection();
conn.setConnectTimeout(5000);
InputStream is = conn.getInputStream();
StringWriter writer = new StringWriter();
IOUtils.copy(is, writer, "UTF-8");
String jsonStr = writer.toString();
我可以使用相对路径执行此操作,以便它在本地和部署的实例上都可以工作吗?