Adobe 无法在Adode CQ5中发布表单

Adobe 无法在Adode CQ5中发布表单,adobe,aem,Adobe,Aem,我是AdobeCQ5的新手。我在邮寄表格方面遇到了一些麻烦。这是我的结构- /apps/<myproject>/components/mytestcomponent mytestcompent.jsp具有以下代码- <form id="myForm" action="<%=resource.getPath()+".html" %>"> <input type="text" id="t1" class="input-small" placeho

我是AdobeCQ5的新手。我在邮寄表格方面遇到了一些麻烦。这是我的结构-

/apps/<myproject>/components/mytestcomponent
mytestcompent.jsp具有以下代码-

<form id="myForm"  action="<%=resource.getPath()+".html" %>">
    <input type="text" id="t1" class="input-small" placeholder="Temprature F" />
    <input type="text" id="t2" class="input-small" placeholder="Temprature C" readonly/>
    <button type="button" id="cbtn" class="btn">Convert</button>
</form>

<script>
    $(document).ready(function() {
        $('#cbtn').click(function ()  {        
            var URL = $("#myForm").attr("action");   
            alert(URL); 
            var t1=$("#t1").val();
            var t2=$("#t2").val();
            $.ajax({
                url: URL,
                data:{'t1':t1},
                type:"post",
                success: function(data, status) {
                    $("#t2").val(data);
                },
                error: function( xhr, txtStat, errThrown ) {
                    alert("ajax  error! " + txtStat + ":::" + errThrown);
                }
            }); 
        }); 
    });    
</script>
这使我的响应代码200成功,但输出不理想。MyMyComponent.POST.jsp包含以下代码-

<%
    // TODO add you code here
    String t1=request.getParameter("t1");
%>
<%= t1 %>
它给出以下输出

  Content modified /content/imobile/en/jcr:content/social.html
  Status    
  200
  Message   
  OK
  Location     /content/imobile/en/_jcr_content/social.html
  Parent Location  /content/imobile/en/_jcr_content
  Path  
  /content/imobile/en/jcr:content/social.html
  Referer http://example.comt:4502/content/imobile/en.html
  ChangeLog 
 <pre></pre>
 Go Back
 Modified Resource
 Parent of Modified Resource

请帮助解决此问题。

处理组件POST方法的JSP文件应命名为POST.JSP,而不是mycomponent.POST.JSP

请注意,如果截获对组件的所有POST请求,您将无法使用对话框在author实例上编辑它,因为该对话框只是将数据发布到组件URL。要避免使用,请考虑使用自定义选择器(如表单)。您的表单应声明如下:

@SlingServlet(
    resourceTypes="myproject/components/mytestcomponent",
    methods="POST",
    selectors="form")

处理组件POST方法的JSP文件应命名为POST.JSP,而不是mycomponent.POST.JSP

请注意,如果截获对组件的所有POST请求,您将无法使用对话框在author实例上编辑它,因为该对话框只是将数据发布到组件URL。要避免使用,请考虑使用自定义选择器(如表单)。您的表单应声明如下:

@SlingServlet(
    resourceTypes="myproject/components/mytestcomponent",
    methods="POST",
    selectors="form")

谢谢编辑。谢谢编辑。不客气。如果你觉得答案有用,就考虑接受。谢谢@TomekRękawek!关于使用选择器来区分通过表单和对话框发出的POST请求的额外信息是上帝的恩赐,不客气。如果你觉得答案有用,就考虑接受。谢谢@TomekRękawek!关于使用选择器区分通过表单和通过对话框发出的POST请求的额外信息位是一个天赐良机