毕业设计-1.16

情况概述:

  今天复习了可视化的内容,关于echarts以及图表的展示。对servlet的编写。

代码如下:

package com.zlc.servlet;

import java.io.IOException;
import java.util.ArrayList;
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.zlc.dao.IWeatherDao;
import com.zlc.dao.impl.WeatherDaoImpl;
import com.zlc.entity.WeatherBean;
import com.zlc.service.IWeatherService;
import com.zlc.service.impl.WeatherServiceImpl;

/**
 * @author Zhao Lucang
 * @version 创建时间:2021年2月26日 下午10:31:02 类说明
 */
public class WeatherSearch01 extends HttpServlet {

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

    /**
     * Destruction of the servlet. <br>
     */
    public void destroy() {
        super.destroy(); // Just puts "destroy" string in log
        // Put your code here
    }

    /**
     * The doGet method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to get.
     * 
     * @param request  the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException      if an error occurred
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // 定义接收编码
        request.setCharacterEncoding("UTF-8");
        // 定义输出
        response.setContentType("text/html");
        response.setCharacterEncoding("utf-8");
        String City=request.getParameter("City");
        int Date=Integer.parseInt(request.getParameter("Date"));
        IWeatherService service = new WeatherServiceImpl();
        IWeatherDao dao = new WeatherDaoImpl();
        List<WeatherBean> weathers = new ArrayList<WeatherBean>();
        weathers = service.queryAllWeathersByCityDate(City, Date);
        request.setAttribute("weathers", weathers);
        request.getRequestDispatcher("../Demo01.jsp").forward(request, response);
        //response.sendRedirect("../Demo02.jsp");
    }

    /**
     * The doPost method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to post.
     * 
     * @param request  the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException      if an error occurred
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doGet(request, response);
    }

    /**
     * Initialization of the servlet. <br>
     *
     * @throws ServletException if an error occurs
     */
    public void init() throws ServletException {
        // Put your code here
    }

}
原文地址:https://www.cnblogs.com/zlc364624/p/14461049.html