如何在Appengine中使用Java Servlet编辑记录

时间:2013-07-13 16:37:58

标签: java google-app-engine jsp servlets google-cloud-datastore

经过大量研究后,我能够通过以下内容向Google Appengine插入记录。但是,现在我遇到了一个问题:我无法使用GQL或SQL语法之后的查询编辑记录。请帮忙!

public class AppointmentServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {

    Date dateLog = new Date();
    String merchant = req.getParameter("merchant");
    String date = req.getParameter("date");
    String time = req.getParameter("time");
    String strDateTime = date + " " + time;
    Date dateTime = null;
    try {
        dateTime = new SimpleDateFormat("dd/MM/yyyy HH:mm").parse(strDateTime);
    } catch (ParseException e) {
    }
    String service = req.getParameter("service");
    String personnel = "Internet Booking";
    String name = req.getParameter("name");
    String phone = req.getParameter("phone");
    String email = req.getParameter("email");
    String request = req.getParameter("request");

    if(email.isEmpty()) {
        email = "-";
    } 

    if(request.isEmpty()) {
        request = "-";
    }

    Appointment appt = new Appointment(dateLog, merchant, dateTime, service, personnel, name, phone, email, request);

    PersistenceManager pm = PMF.get().getPersistenceManager();
    try {
        pm.makePersistent(appt);
    } finally {
        pm.close();
    }

    resp.sendRedirect("/appointment/complete.jsp");
}

}

我有一个“编辑”表单,可以编辑任何字段。所以请帮忙!谢谢!

2 个答案:

答案 0 :(得分:0)

  1. 我认为它与App Engine无关。
  2. 你应该看看那里的各种各样的例子。
  3. 一个简单的谷歌搜索给了gave nice results.
  4. 如果您无法获得示例,可以在此处发布有关特定疑问或示例网站的其他问题。

答案 1 :(得分:0)

查看此question

存储数据下的代码