欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

用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);
%>