spring mvc - parameter passing from jsp to controller - page redirect

380 Views Asked by At

I've a spring web application. I'm passing a parameter from controllerA to jsp1.jsp page. This page after 5sec will redirect to jsp2.jsp. During the redirect the request goes through controllerA. I would like to know how do I pass the parameter from jsp1.jsp to controllerA. here is my controllerA method

 @RequestMapping(value="/jsp2", method = RequestMethod.GET)
 public String jsp2(ModelMap model) {

    // code to access the parameter from jsp1.jsp

    return "/pages/jsp2";
 }
1

There are 1 best solutions below

0
On

Depends on how you are passing the parameter. If you are passing it as a query parameter, you can access it like below

@RequestMapping(value="/jsp2", method = RequestMethod.GET)
 public String jsp2(@RequestParam("param") String param, ModelMap model) {
    log.info("Got parameter " + param);
    return "/pages/jsp2";
 }