0

I'm trying to call Spring Controller from JS with a requesParam but I'm always getting Required String parameter 'id' is not present

The call in my JSP:

window.location.href='controllerTest/controller1/function1?id='+idFromJSFunction;

My Controller:

@Controller
@RequestMapping(value = "/controller1")
public class Controller1{

    @RequestMapping(value = "/function1")
    public ModelAndView function1(@RequestParam("id") String idFromJSP, HttpServletRequest request,
        RedirectAttributes redAttr) {

    //Doing things
    }

}

If I put reuired=false, id is always null.

Any hint?

canillas
  • 414
  • 3
  • 13
  • 1
    probably `idFromJSFunction` is empty – PKey Feb 23 '18 at 09:49
  • @Plirkee idFromJSFunction is not empty because I can see that URL is correct. When I make the call I can see in the browser: http:// localhost:7001/rootContext/controllerTest/controller1/function1?id=6 – canillas Feb 23 '18 at 09:50

0 Answers0