如何从参数请求的值迭代

时间:2015-02-28 14:41:27

标签: java spring hibernate

我正在开发一个使用Spring MVC和hibernate的Web应用程序,

我有这样的数据,

enter image description here

在网络界面上,我发送'MESSAGEID'作为请求,

'MESSAGEID'不是唯一的,所以我想迭代参数请求(MESSAGEID)的值来检查数据并获取TRANSACTION ='PAYMENT'和SUBTRANSACTION ='PROCESSED'的数据,

这是我的代码,

@RequestMapping(value="/admin/Detail-BPJS-TK.html")
public ModelAndView listDetailBPJSTK(ModelMap model, HttpServletRequest request, HttpServletResponse response)throws ParserConfigurationException, Exception{
    if(!((request.getParameter("MESSAGEID")) == null)){
        String MESSAGEID = request.getParameter("MESSAGEID");
        System.out.println(MESSAGEID);

        DetailBPJS detailbpjs = detailbpjsService.get(MESSAGEID);

        String tes = detailbpjs.getMESSAGEID();
        System.out.println(tes);

        if (!(detailbpjs) == null){
            for (DetailBPJS luna : detailbpjs){
                String trans = detailbpjs.getTRANSACTION();
                String subtr = detailbpjs.getSUBTRANSACTION();

                if(trans == "PAYMENT" && subtr == "PROCESSED"){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
            }
        }           
    }else{
        System.out.println("Please, check the 'No. Billing' again!!");
        String MESSAGEID = request.getParameter("MESSAGEID");
        System.out.println(MESSAGEID);
        model.addAttribute("errorMessageBPJSTK", "true");
    }

    return listDetailBPJS(model);
}

任何帮助都会很愉快:)

1 个答案:

答案 0 :(得分:0)

尝试使用request.gerParameterValues(name)。

此方法返回一个包含特定参数的所有值的数组。