상세 컨텐츠

본문 제목

java submit html form

프로그램 언어/Java

by husks 2015. 2. 17. 19:16

본문

반응형

자바에서 html form형식으로 submit하는 예제입니다.

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.PostMethod;

    HttpClient httpClient = new HttpClient();
    PostMethod postMethod = new PostMethod(url); //url에 주소를 적어주세요.
    postMethod.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=EUC-KR");
    postMethod.addParameter("mail_code", smsMailCode1);
    postMethod.addParameter("user_id", smsUserId);
    postMethod.addParameter("auth_key", smsAuthKey1);
    postMethod.addParameter("mem_id", mem_id);
    postMethod.addParameter("mem_name", mem_name);
    postMethod.addParameter("mem_phone", mem_phone);
    postMethod.addParameter("M1", M1);
    postMethod.addParameter("M2", M2);
    postMethod.addParameter("M3", M3);
   
    try {
        httpClient.executeMethod(postMethod);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }


반응형

관련글 더보기

댓글 영역