简体   繁体   English

将Custom对象从servlet传递到ajax并显示在jsp页面中

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

Is that any method to pass custome object from servlet to ajax and display in jsp page? 有什么方法可以将定制对象从servlet传递到ajax并显示在jsp页面中? When accept inventory id from jsp page, it pass to servlet and get the inventory object based on the id. 当从jsp页面接受库存ID时,它将传递到servlet并根据该ID获取库存对象。 After that, i want to pass the inventory object back to the ajax and display in jsp page 之后,我想将清单对象传递回ajax并在jsp页面中显示

This might be your answer as you did not describe your problem in deep. 这可能是您的答案,因为您没有深入描述问题。

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