Reputation: 133
I have a boolean function in a java class.. the function returns true if executed else it has to be directed to a jsp page how do I do that.. I am not using any creation of objects nor req.getParameter().. I tried using redirectView()
, its a function and getting errors.
Its something like..
boolean isValidate()
{
}
if(isValidate())
return true;
else
Upvotes: 1
Views: 746
Reputation: 9505
Try on your controller
Normal GET:
return "path/to/jsp";
Redirect:
return "redirect:/login";
When use redirect prefix, it will return to http://host/yourapp/login
Spring documentation for redirect prefix
For redirect example:
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logoit() {
return "redirect:/";
}
Upvotes: 2
Reputation: 8414
Assuming your controller method returns a String, you can do:
return "redirect:/path/to/page";
Upvotes: 1