91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 8KB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-03
  • 語言: Java
  • 標簽: 天氣預報??web??

資源簡介

該代碼使用的api接口為:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather?theUserId=&theCityCode=792,可以預測未來5天的粗略天氣(包括今天)。 適合初學的朋友使用。界面很丑。

資源截圖

代碼片段和文件信息

package?com.servlet;

import?java.io.IOException;
import?java.io.PrintWriter;
import?java.util.List;

import?javax.servlet.ServletException;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;

import?com.weather.WeatherUtil;

public?class?WeatherServlet?extends?HttpServlet?{

/**
?*?Constructor?of?the?object.
?*/
public?WeatherServlet()?{
super();
}

/**
?*?Destruction?of?the?servlet.?

?*/
public?void?destroy()?{
super.destroy();?//?Just?puts?“destroy“?string?in?log
//?Put?your?code?here
}


public?void?doGet(HttpServletRequest?request?HttpServletResponse?response)
throws?ServletException?IOException?{

response.setContentType(“text/html“);
doPost(request?response);
}


public?void?doPost(HttpServletRequest?request?HttpServletResponse?response)
throws?ServletException?IOException?{

???request.setCharacterEncoding(“UTF-8“);
response.setContentType(“text/html;charset=utf-8“);
response.setCharacterEncoding(“utf-8“);

String?provinceStr?=?request.getParameter(“provinceCode“);
String??cityStr?=request.getParameter(“cityCode“);
System.out.println(provinceStr?+?“?“?+?cityStr);


WeatherUtil?db?=new?WeatherUtil();
int?provinceCode?=db.getProinceCode(provinceStr);
System.out.println(provinceCode);
int?cityCode?=?db.getCityCode(provinceCode?cityStr);
System.out.println(cityCode?);

List?list=db.getWeather(cityCode);

response.setContentType(“text/html“);
PrintWriter?out?=?response.getWriter();
out.println(““);
out.println(““);
out.println(“??tle>A?Servlettle>“);
out.println(“??“);
for(String?s:list){
out.print(s);
out.print(“
“);
}
????????out.println(“??“);
out.println(““);
out.flush();
out.close();
}

/**
?*?Initialization?of?the?servlet.?

?*
?*?@throws?ServletException?if?an?error?occurs
?*/
public?void?init()?throws?ServletException?{
//?Put?your?code?here
}

}

評論

共有 條評論