The request variable is declared, but not initialized. No wonder you get a NullPointerException .
See the documentation for access to various query related data.
After you read this and make sure you want to bind your code to the Servlet native API, try the following:
@Controller class MyController { @RequestMapping public void handleMe(HttpServletRequest request) { String path = request.getContextPath(); } }
Roadrunner
source share