I am defining a context-param in web.xml of my application as below
baseUrl
Make your Controller implement the ServletContextAware interface. This will force you implement a setServletContext(ServletContext servletContext) method and Spring will inject the ServletContext in it. Then just copy the ServletContext reference to a private class member.
public class MyController implements ServletContextAware {
private ServletContext servletContext;
@Override
setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
}
You can get the param-value with:
String urlValue = servletContext.getInitParameter("baseUrl");