updateweatherforecastservlet.java
来自「买书附带的光盘资料Foundations_Of_Ajax中文版教程及源代码。 」· Java 代码 · 共 34 行
JAVA
34 行
package ajaxdashboard.servlet;import ajaxdashboard.service.WeatherForecastService;import java.io.*;import java.util.Date;import javax.servlet.*;import javax.servlet.http.*;public class UpdateWeatherForecastServlet extends HttpServlet { protected void processRequest(HttpServletRequest request , HttpServletResponse response) throws ServletException, IOException { String zipCode = request.getParameter("forecastZipCode"); WeatherForecastService forecastService = new WeatherForecastService(); request.setAttribute("forecastData" , forecastService.getForecastFor(zipCode)); System.out.println("Weather updated at: " + new Date().toString()); request.getRequestDispatcher("/jsp/weather/weatherForecastAjax.jsp") .forward(request, response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?