使用「提交至REST端點」動作,將提交的資料發佈至REST URL。 URL可以是內部(呈現表單的伺服器)或外部伺服器。
通常客戶會想要將表單資料提交至外部伺服器,以便進一步處理。
若要將資料發佈到內部伺服器,請提供資源的路徑。 資料會張貼在資源的路徑中。 例如, </content restendpoint=""> . 對於此類貼文請求,會使用提交請求的驗證資訊。
若要將資料發佈至外部伺服器,請提供URL。 URL的格式為 http://host:port/path_to_rest_end_point. 確保您已設定匿名處理POST請求的路徑。
出於本文的目的,我撰寫了一個簡單的war檔案,可部署在您的tomcat執行個體上。 假設您的tomcat在連線埠8080上執行,則POSTurl將為
http://localhost:8080/AemFormsEnablement/HandleFormSubmission
當您設定最適化表單以提交至此端點時,表單資料和附件(若有)可透過下列程式碼擷取到servlet中
System.out.println("form was submitted");
Part attachment = request.getPart("attachments");
if(attachment!=null)
{
System.out.println("The content type of the attachment added is "+attachment.getContentType());
}
Enumeration<String> params = request.getParameterNames();
while(params.hasMoreElements())
{
String paramName = params.nextElement();
System.out.println("The param Name is "+paramName);
String data = request.getParameter(paramName);System.out.println("The data is "+data);
}
若要在您的伺服器上測試此專案,請執行下列動作