用javascript为页面添加天气显示实现思路及代码_javascript技巧
程序员文章站
2022-06-01 18:05:25
...
复制代码 代码如下:
天气情况
date.jsp
复制代码 代码如下:
String cid = request.getParameter("cid");
URL url = new URL("http://m.weather.com.cn/data/"+cid+".html");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.connect();
InputStream cin = httpConn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(cin,"UTF-8"));
StringBuffer sb = new StringBuffer();
String rl = null;
while ((rl = reader.readLine()) != null)
sb.append(rl);
out.println(sb);
%>