-
Use below code to autowire
ServletContextobject in SpringMVC@Autowired ServletContext context;and after that try to execute your code like
String uploadPath = context.getRealPath("") + File.separator + UPLOAD_DIRECTORY; -
You can get it in your controller like this;
private ServletContext context; public void setServletContext(ServletContext servletContext) { this.context = servletContext; }but for this your controller must implement
ServletContextAwareinterface