Friday 4 January 2013

Textual Representation of logo

Spring 3 MVC RequestParam 400 Error

if we use RequestParam annotation in Spring Controller like this :


@RequestMapping(value="/viewFileDetails",method=RequestMethod.GET)
 public String getDetails(Model model,@RequestParam String userId){
  if(userId !=null && !userId.isEmpty())
  {
   List beans = fileDetailsDAO.getPermittedFiles(Integer.parseInt(userId));
   model.addAttribute("files",beans);
  }
  return "viewFileDetails";
 }
now spring will expect userId parameter in query string of the url. If we fail to provide the value for this parameter we get following 400 error . so the url should be like /viewFileDetails?userId=12 or we can add @RequestParam(required=false) in the annotation to mark this parameter optional

The request sent by the client was syntactically incorrect ()