먼저 "/WEB-INF/views/searchResult.jsp"보기로 이동 한 다음 Calculator.lookUp (Type, Place)를 백그라운드로 처리하고 싶습니다.JSP - 먼저보기로 전달한 다음 백그라운드에서 처리 방법을 계속 수행 하시겠습니까?
현재 Calculator.lookUp (Type, Place)가 먼저 처리되고 사용자가 "/WEB-INF/views/searchResult.jsp"로 전달되는 경우에만이 메소드가 완료됩니다. 도움에 감사드립니다!
@WebServlet(urlPatterns="/search.do")
public class SrchServlet extends HttpServlet{
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String Type = request.getParameter("Type");
String Place = request.getParameter("Place");
request.setAttribute("Type", Type);
request.setAttribute("Place", Place);
//I want the forward to searchResult.jsp to occur
request.getRequestDispatcher("/WEB-INF/views/searchResult.jsp").forward(
request, response);
//and then in backend for the below method to run
Calculator.lookUp(Type, Place);
}
}
당신은 비동기 요청을 통해 원하는 결과를 얻을 수 있습니다. [이해 동기식 대 비동기식] (https://www.javatpoint.com/understanding-synchronous-vs-asynchronous) –
고마워, 그건 이해가되지만, 내가 어떻게 위의 비동기 요청 암호. – Padoga