當前位置: 首頁>>代碼示例>>Java>>正文


Java PostMethod.setParameter方法代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.methods.PostMethod.setParameter方法的典型用法代碼示例。如果您正苦於以下問題:Java PostMethod.setParameter方法的具體用法?Java PostMethod.setParameter怎麽用?Java PostMethod.setParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.httpclient.methods.PostMethod的用法示例。


在下文中一共展示了PostMethod.setParameter方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processorsActive

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
@Test
public void processorsActive() throws HttpException, IOException {
    final PostMethod post = new PostMethod(testUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX);
    post.setFollowRedirects(false);
    post.setParameter("DummyModification", "true");

    try {
        T.getHttpClient().executeMethod(post);
        final String content = post.getResponseBodyAsString();
        final int i1 = content.indexOf("source:SlingPostProcessorOne");
        assertTrue("Expecting first processor to be present", i1 > 0);
        final int i2 = content.indexOf("source:SlingPostProcessorTwo");
        assertTrue("Expecting second processor to be present", i2 > 0);
        assertTrue("Expecting service ranking to put processor one first", i1 < i2);
    } finally {
        
        post.releaseConnection();
    }

}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:21,代碼來源:SlingPostProcessorTest.java

示例2: testDeleteNonExisting

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
@Test
public void testDeleteNonExisting() throws Exception {
    final String path = TEST_PATH + "/" + EXISTING_PATH;
    final String testNodeUrl = H.getTestClient().createNode(HttpTest.HTTP_BASE_URL + "/" + path, null);
    assertTrue("Expecting created node path to end with " + path, testNodeUrl.endsWith(path));
    H.assertHttpStatus(testNodeUrl + ".json", 200, "Expecting test node to exist before test");

    // POST :delete to non-existing child node with a path that
    // generates selector + suffix
    final String selectorsPath = TEST_PATH + "/" + deletePath;
    final PostMethod post = new PostMethod(HttpTest.HTTP_BASE_URL + "/" + selectorsPath);
    post.setParameter(":operation",  "delete");
    final int status = H.getHttpClient().executeMethod(post);
    assertEquals("Expecting 403 status for delete operation", 403, status);

    // Test node should still be here
    H.assertHttpStatus(testNodeUrl + ".json", 200, "Expecting test node to exist after test");
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:19,代碼來源:PostServletDeleteParentTest.java

示例3: setPostParams

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
private static void setPostParams(PostMethod postMethod,Map<String,Object> params){
	for (String name : params.keySet()) {
		postMethod.setParameter(name,String.valueOf(params.get(name)));
		//parts[i++] = new StringPart(name, String.valueOf(params.get(name)), UTF_8);
		// System.out.println("post_key==> "+name+"    value==>"+String.valueOf(params.get(name)));
	}
}
 
開發者ID:PlutoArchitecture,項目名稱:Pluto-Android,代碼行數:8,代碼來源:ApiClient.java

示例4: post

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
public String post(String postURL, Map<String, String> partam, String cookies)
            throws IOException {
//        clearCookies();
        PostMethod p = new PostMethod(postURL);
        for (String key : partam.keySet()) {
            if (partam.get(key) != null) {
                p.setParameter(key, partam.get(key));
            }
        }
        if (StringUtils.isNotEmpty(cookies)) {
            p.addRequestHeader("cookie", cookies);
        }
        hc.executeMethod(p);
        return p.getResponseBodyAsString();
    }
 
開發者ID:bruceq,項目名稱:Gather-Platform,代碼行數:16,代碼來源:HttpClientUtil.java

示例5: postRegisterState

import org.apache.commons.httpclient.methods.PostMethod; //導入方法依賴的package包/類
public void postRegisterState(final String page) {
	if (!page.equals(previousPageName)) {
		previousPageName = page;
		Thread th = new Thread(new Runnable() {

			public void run() {
				synchronized (SetupWizard.this) {

					try {
						String[] url = { "http://www.google-analytics.com/collect" };
						HttpClient client = prepareHttpClient(url);
						PostMethod method = new PostMethod(url[0]);
						HeaderName.ContentType.setRequestHeader(method, MimeType.WwwForm.value());

						// set parameters for POST method
						method.setParameter("v", "1");
						method.setParameter("tid", "UA-660091-6");
						method.setParameter("cid", getUniqueID());
						method.setParameter("t", "pageview");
						method.setParameter("dh",
								"http://www.convertigo.com");
						method.setParameter("dp",
								"/StudioRegistrationWizard_" + page
										+ ".html");
						method.setParameter("dt", page + "_"
								+ ProductVersion.productVersion);

						// execute HTTP post with parameters
						if (client != null) {
							client.executeMethod(method);
						}
					} catch (Exception e) {
						// ConvertigoPlugin.logWarning(e,
						// "Error while trying to send registration");
					}
				}
			}
		});
		th.setDaemon(true);
		th.setName("SetupWizard.register_steps");
		th.start();
	} else {
		previousPageName = page;
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:46,代碼來源:SetupWizard.java


注:本文中的org.apache.commons.httpclient.methods.PostMethod.setParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。