에서 값을 얻을 :어떻게 다음 코드를 사용하는 클라이언트 측에서 HttpMethodParams
@RequestMapping("/requestTest")
public void requestTest(HttpServletRequest request) throws IOException {
String userId = request.getParameter("userId");
String identity= request.getParameter("identity");
String phoneNum= request.getParameter("phoneNum");
System.out.println(userId+identity+phoneNum);
}
하지만 난 널을 가지고 :
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("userId", "1579533296");
paramMap.put("identity", "352225199101195515");
paramMap.put("phoneNum", "15959177178");
HttpClient client = new HttpClient();
PostMethod method = new PostMethod("http://localhost:8088/requestTest");
HttpMethodParams p = new HttpMethodParams();
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
p.setParameter(entry.getKey(), entry.getValue());
}
method.setParams(p);
client.executeMethod(method);
그리고 내 서버 측의 코드는이처럼 userId, identity 및 phoneNum 값은 어떻게 값을 얻을 수 있습니까? 나는 method.setParameter (key, value)를 사용하여 클라이언트 측에서 매개 변수를 설정하고 getParameter (key)를 사용하여 매개 변수 값을 얻을 수 있음을 알고 있지만 서버 측에서 값을 가져 오는 방법이 있다면 궁금하다. HttpMethodParams에 의해.
이렇게 ... 서버 측에서 이러한 종류의 측광을 얻을 수있는 방법이 없다는 것을 의미합니까? 나는 방법을 사용할 수 있다는 것을 안다.setParameter (key, value) 클라이언트 쪽에서 매개 변수를 설정하고 getParameter (key)를 사용하여 매개 변수 값을 가져 오지만, HttpMethodParams에 의해 설정된 서버 쪽에서 값을 가져 오는 방법이 있는지 궁금합니다. – zhenganyi
나는 내 대답을 업데이트했다. ... 클라이언트 측 용어는 서버 측에 적용 할 수 없습니다. –