然后还有@Param (是否是代码中的setMethodArgs这个方法设置,还是在其它地方设置).以及adapt的实现方法,这里只定义了一个接口,没有实现方法.
public void process(ActionContext ac) throws Throwable {
List<String> phArgs = ac.getPathArgs();
Object[] args = adaptor.adapt(ac.getServletContext(),
ac.getRequest(),
ac.getResponse(),
phArgs.toArray(new String[phArgs.size()]));
ac.setMethodArgs(args);
doNext(ac);
}
获取到的 args :
[{}, org.apache.catalina.connector.RequestFacade@39e308c9]
设置entity代码:
public String sendHttpPost(String httpUrl, String params, String contentType) {
HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost
try {
// 设置参数
StringEntity stringEntity = new StringEntity(params, "UTF-8");
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType(contentType);
httpPost.addHeader("Content-Type", contentType);
httpPost.setEntity(stringEntity);
} catch (Exception e) {
e.printStackTrace();
}
//调的是execute 方法.
return sendHttpPost(httpPost);
}