簡體   English   中英

將Custom對象從servlet傳遞到ajax並顯示在jsp頁面中

[英]Pass Custom object from servlet to ajax and display in jsp page

有什么方法可以將定制對象從servlet傳遞到ajax並顯示在jsp頁面中? 當從jsp頁面接受庫存ID時,它將傳遞到servlet並根據該ID獲取庫存對象。 之后,我想將清單對象傳遞回ajax並在jsp頁面中顯示

這可能是您的答案,因為您沒有深入描述問題。

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Test extends HttpServlet {

  // Method to handle GET method request.
  public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
  {
      //declaring custom object
      Person person = new Person("FirstName","LastName");

      PrintWriter out = response.getWriter();
      out.print(person);
  }
  // Method to handle POST method request.
  public void doPost(HttpServletRequest request,
                     HttpServletResponse response)
      throws ServletException, IOException {
     doGet(request, response);
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM