commons-httpclient-3.1

jar 包:commons-httpclient-3.1.jar

eg:

/**
* 发送预警邮件
*/
public void sendMail(Integer orgId,String orgName,String cashName,Long totalAmount,Long prewaringValue){
try {

HttpClient httpclient=new HttpClient();
PostMethod postmethod=new PostMethod("http://"+MURL+":8080/SimpleMail/servlet/message/mailcash");
postmethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"utf-8");
String orgIdStr = String.valueOf(orgId);
NameValuePair[] date = {
new NameValuePair("orgId",orgIdStr),
new NameValuePair("orgName",orgName),
new NameValuePair("cashName",cashName),
new NameValuePair("totalAmount",""+(new BigDecimal(totalAmount).divide(new BigDecimal("10000"), BigDecimal.ROUND_HALF_UP))),
new NameValuePair("prewaringValue",""+(new BigDecimal(prewaringValue).divide(new BigDecimal("10000"), BigDecimal.ROUND_HALF_UP))),
};
postmethod.setRequestBody(date);
httpclient.executeMethod(postmethod);
} catch (Exception e) {
LoggerUtil.info("====send mail error==="+e);
}
}

posted on 2016-10-20 10:31  糖糖╭❤~  阅读(264)  评论(0编辑  收藏  举报