0

我正在尝试在 AEM 6.1 中开发 AMP 表单并尝试将数据提交到后端 sling servlet 以将数据保存到数据库中。但我得到了错误的回报:

<body>
<form class="sample-form"
  method="post"
  action-xhr="/bin/rating.rest"
  target="_top">
  <input type="text"
    name="name"
    placeholder="Name..."
    required>
  <input type="email"
    name="email"
    placeholder="Email..."
    required>
      <input type="text"
    name="title"
    placeholder="Title..."
    required>
    <input type="textarea"
    name="textarea"
    placeholder="Feedback..."
    required>

     <fieldset class="rating">
      <input name="rating" type="radio" id="rating5" value="5" on="change:rating.submit">
      <label for="rating5" title="5 stars">☆&lt;/label>

      <input name="rating" type="radio" id="rating4" value="4" on="change:rating.submit">
      <label for="rating4" title="4 stars">☆&lt;/label>

      <input name="rating" type="radio" id="rating3" value="3" on="change:rating.submit" checked="checked">
      <label for="rating3" title="3 stars">☆&lt;/label>

      <input name="rating" type="radio" id="rating2" value="2" on="change:rating.submit" >
      <label for="rating2" title="2 stars">☆&lt;/label>

      <input name="rating" type="radio" id="rating1" value="1" on="change:rating.submit">
      <label for="rating1" title="1 stars">☆&lt;/label>
    </fieldset>
      <input type="submit"
    value="Submit Feedback">
  <div submit-success>
    <template type="amp-mustache">
      Success! Thanks {{name}} for trying the <code>amp-form</code> demo! Try to insert the word "error" as a name input in the form to see how <code>amp-form</code> handles errors.
    </template>
  </div>
  <div submit-error>
    <template type="amp-mustache">
      Error! Thanks {{name}} for trying the <code>amp-form</code> demo with an error response.
    </template>
  </div>
</form>
</body>

后端代码::::

@SlingServlet(paths="/bin/rating.rest", methods = "POST", metatype=true)

公共类 AmpRatingActionServlet 扩展 SlingAllMethodsServlet {

    protected void doPost(SlingHttpServletRequest request,SlingHttpServletResponse response) throws ServletException,
        IOException {

    String jsonData = null;
    String name;
    String email;
    String title;
    String textarea;
    String rating;
    try
    {
    name = request.getParameter("name");
    email = request.getParameter("email");
    title = request.getParameter("title");
    textarea = request.getParameter("textarea");
    rating = request.getParameter("rating");
    log.info(CLASSNAME+"::Inside Try Block:::::::name::::"+name+":::::email:::::"+email+":::::title:::::"+title+":::::textarea:::::"+textarea+":::::rating:::::"+rating);
    }
            }catch(Exception e) {
      log.error(Error occurred in Servlet", e);
   }
}

500 消息 javax.jcr.nodetype.ConstraintViolationException:没有匹配的属性定义:名称 = 测试

4

0 回答 0