I am using spring annotations I have written one method
public ModelAndView showTestPage(@RequestParam("firstInstanceId") String id1, @RequestParam("secondInstanceId") String id2, HttpSession session) { ModelAndView mv = new ModelAndView("showCompareItemList"); mv.addObject("pageTitle", "showCompareItemList"); mv.addObject("firstInstanceId", id1); mv.addObject("secondInstanceId", id2); return mv; }
when there both values of id1 and id2 are present it works fine but when there is only one value i get exception org.springframework.web.bind.MissingServletRequestParameterException: Required java.lang.String parameter 'secondInstanceId' is not present I tried resolve this problem by checking null but still i am getting this exception can anybody tell me what should I do to avoid this excpetion?