如何在我的jersey servlet中使用curl请求中的表单参数的哈希映射?

时间:2015-08-05 11:09:19

标签: java curl hashmap jersey jax-rs

我正在提出一个卷曲请求:

curl -i -X POST -d "debit_user_id=/customer/mobile_number:917827448775&recipient_id=/customer/mobile_number:9988776655/recipients/mobile_number:917526337452&pintwin=1234&amount=5000&currency=INR&customer_id=/customer/mobile_number:9988776655&agent_id=/agents/mobile_number:919987536699" http://localhost:8080/switch/apikongcall.do/transactions

我在我的球衣servlet中得到这些参数,如:

@POST
//@Path("/transactions")
@Consumes("application/x-www-form-urlencoded")
public void initiatePostTransaction(@FormParam("debit_user_id") String debit_user_id,
        @FormParam("recipient_id") String recipient_id,
        @FormParam("pintwin") String pintwin,
        @FormParam("amount") String amount,
        @FormParam("currency") String currency,
        @FormParam("customer_id") String customer_id,
        @FormParam("agent_id") String agent_id) {

我的问题是,我可以为这些参数创建一个hashmap,所以我不需要单独提取这些参数。我开玩笑地需要hashmap,所以即使有人稍后添加了一个新参数,我也不需要改变任何东西。有没有办法在球衣中删除这种依赖。?

0 个答案:

没有答案
相关问题