Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Controller for springboot that redirects any url to /
@Controller
public class ForwardingController {
@RequestMapping("/**/{path:[^\\.]+}")
public String forward() {
// path: checks only the path of url
// [^\.]: any char, except literal dot (because if the url is foo.css (for example) we don't want to redirect)
return "forward:/";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment