【问题标题】:Getting error while submitting form data using post method in AEM / CQ在 AEM / CQ 中使用 post 方法提交表单数据时出错
【发布时间】:2016-01-21 16:20:10
【问题描述】:

有一个cq页面,页面中有很多组件。在一个组件中,我们有 HTML 表单代码。提交表单数据后,我需要在 PageContext 中设置所有值,并在同一页面上的其他组件中使用这些值。

为了实现这一点,我创建了名为“MySamplecomponent”的组件。并将所有 html 代码放入如下。我还在同一组件下创建了一个 POST.jsp。 Mysamplecompnent.jsp 代码

<%@include file="/libs/foundation/global.jsp"%>

<%
    //String collapsed = properties.get("selection","");
    String collapsed= request.getParameter("testKey");
    out.println("value++"+collapsed);
String category= request.getParameter("skill");
out.println("Category++"+category);
pageContext.setAttribute("collapsed1",collapsed,PageContext.REQUEST_SCOPE);

%>

<form  name="form1" id="form1" action="${currentPage.path}.html" method="post">  
    <input type ="text" name="testKey" id="testKey" value="collapsed" />
    <input type ="hidden" name="pathValue" id="pathValue" value="myValue" />
    <select name="skill" style="display:block">
     <option value="1">Cricket</option>
        <option value="2">Volley ball</option>
        <option value="3">Tennis</option>
</select>
    <input type="radio" name="ravi" id="radiobutton" value="success" > radiobutton<br>
      <input id="SubmitButton" name="SubmitButton" type="submit" value="SubmitButton"  onclick="javascript:location.href='#'" />
</form> 

点击提交按钮后出现以下错误

处理 /content/myPage/ 时出错

状态
500 信息 javax.jcr.nodetype.ConstraintViolationException:没有匹配的属性定义:testKey = collapsed 位置/内容/我的页面/ 父位置/内容 路径
/内容/我的页面/ 推荐人http://localhost:4502/content/myPage.html 变更日志



返回

修改后的资源

已修改资源的父级

【问题讨论】:

    标签: aem


    【解决方案1】:

    首先,我相信你的意思是PageContext下的PageContent。如果要使用 Sling Post Servlet,则需要更改操作。

    ${currentPage.path} 指的是 Page 节点,而不是 PageContent 节点。页面节点对属性有非常严格的限制,您不能在其中放置任何自定义道具,例如 testKey。因此,要使您的代码正常工作,只需将您的 action 属性替换为 ${currentPage.path}/jcr:content 即可。

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-12-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-31
        相关资源
        最近更新 更多