错误: 代理抛出异常错误: java.rmi.server.ExportException: Port already in use: 1099; nested exception is:
java.net.BindException: Address already in use (Bind failed)
具体代码如下:
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException {
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
String jsonStr= null;
try {
jsonStr = this.jsonString();
} catch (JSONException e) {
e.printStackTrace();
}
//array.toString()
PrintWriter out = null;
try {
out = response.getWriter();
out.write(jsonStr);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
out.close();
}
}
}
String jsonString() throws JSONException{
JSONObject json = null;
json = new JSONObject();
json.put("username", "wanglihong");
json.put("height", "12.5");
json.put("age", 24);
String jsonStr= json.toString();
return jsonStr;
}