Servlet代码如下所示
@SlingServlet(
methods = {"POST"},
resourceTypes = {"cq:Page"},
extensions = {"html"})
public class AssetDownloadServlet extends SlingAllMethodsServlet {
private static final Logger log = LoggerFactory.getLogger(AssetDownloadServlet.class);
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException
{
log.info("%%%%%%%%%%%%%%$$$$$$$$$$$%%%%%%%**************: "+ "doPost");
processRequest(request,response);
}
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException
{
log.info("%%%%%%%%%%%%%%$$$$$$$$$$$%%%%%%%**************: "+ "doGet");
processRequest(request,response);
}
private void processRequest(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException{
log.info("%%%%%%%%%%%%%%$$$$$$$$$$$%%%%%%%*******************");
log.info(request.getParameter("format"));
log.info("%%%%%%%%%%%%%%$$$$$$$$$$$%%%%%%%*******************");
}
}
html页面中的表单如下所示
<form method="POST">
<fieldset>
<p>Format needed?</p>
<ul style="list-style-type:none" data-sly-list.rendition="${renditions}">
<!--${rendition.path}-->
<li>
<label>
<input type="radio" name="format" value="${rendition.name}" />
<span>${rendition.displayName}</span>
</label>
</li>
</ul>
</fieldset>
<fieldset>
<button type="submit">Start Download</button>
<a>Cancel Download</a>
</fieldset>
</form>
页面上的CQ详细信息
<!--cq{"decorated":false,"type":"myProject/components/page/generic","path":"/content/myProject/en/assetdetail/jcr:content","selectors":"IRNHUF7D","servlet":"Script /libs/foundation/components/page/page.jsp","totalTime":28,"selfTime":8}-->
要点:
我有一个cq:page资源,表单和servlet链接到它。但是在提交表单时,servlet不会下注。我看到http://localhost:4502/system/console/中的属性设置正确。
请建议..
由于