Gopi
Gopi

Reputation: 620

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

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";
 }

Upvotes: 0

Views: 358

Answers (1)

usha
usha

Reputation: 29349

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";
 }

Upvotes: 1

Related Questions