Variable request
is declared, but is not
initialized. No wonder you get a NullPointerException
.
Look at documentation to access different request related data.
After you read that, and are sure you want to tie your code to native Servlet API, try this:
@Controller
class MyController {
@RequestMapping
public void handleMe(HttpServletRequest request) {
String path = request.getContextPath();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…