目录
功能一:查询所有展示
1.根据城市来进行条件查询
findAllAreaServlet
package com.itheima.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.itheima.pojo.Area;
import com.itheima.service.AreaService;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;
@WebServlet("/findAllAreaServlet")
public class findAllAreaServlet extends HttpServlet {
private ObjectMapper objectMapper = new ObjectMapper();
private AreaService as = new AreaService();
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json;charset=utf-8");
List<Area> areas = as.SelectAllArea();
objectMapper.writeValue(response.getWriter(),areas);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
AreaService