求助帖
自己写的android客户端链接自己写的服务端获取json数据出现了java.net.SocketTimeoutException: Connection timed out 的错误,试了网上所有的方法,还是不行,求助大神。膜拜中。。。。。 android web json --------------------编程问答-------------------- 把它放在线程中执行--------------------编程问答-------------------- 谢谢啊!还是不行。服务端就生成json数据的一段代码。
public class NewsListServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private NewsService service = new NewsServiceBean();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doPost(req,resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
List<News> newes = service.getLastNews();
StringBuilder json = new StringBuilder();
json.append("[");
for(News news : newes) {
json.append("{");
json.append("id:").append(news.getId()).append(",");
json.append("titles:\"").append(news.getTitles()).append("\",");
json.append("timeLength:").append(news.getTimeLength());
json.append("},");
}
json.deleteCharAt(json.length()-1);
json.append("]");
req.setAttribute("json", json.toString());
req.getRequestDispatcher("/WEB-INF/page/jsonnewslist.jsp").forward(req, resp);
}
}
补充:移动开发 , Android