当前位置: 首页>>代码示例>>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;未经允许,请勿转载。