多功能实现查找标签:总结,String,service,request,3.15,getParameter,import,双人,Method From: https://www.cnblogs.com/jy-all-bug/p/17220456.html
package com.jy.web;
import com.jy.pojo.TotalStation;
import com.jy.service.Service;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;
@WebServlet("/ResearchServlet")
public class ResearchServlet extends HttpServlet {
private Service service=new Service();
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String Method=request.getParameter("Method");
if(Method.equals("XLCX"))
{
String routine=request.getParameter("routine");
List <TotalStation> totalStations1=service.research1(routine);
request.setAttribute("totalStations1", totalStations1);
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else if(Method.equals("ZDCX"))
{
String station=request.getParameter("station");
List <TotalStation> totalStations2=service.research2(station);
System.out.println(totalStations2);
request.setAttribute("totalStations2", totalStations2);
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else if(Method.equals("SECX"))
{
String station1=request.getParameter("station1");
String station2=request.getParameter("station2");
service.research3(station1,station2);
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request, response);
}
}