I'm migrating a web app to Spring 3.2 and am enjoying the web.xml-free configuration. One part that's remaining is setting the webapp root key, which I previously did in web.xml like so:
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapproot</param-value>
</context-param>
I know that Spring creates a default key, but in my case I'm running multiple versions of the same war and need to set the key to a different value in each. So optimally I'd like to take a value from a properties file and use that as the rootkey.
I imagine that I would do this somewhere here:
public class WebAppInitializer implements WebApplicationInitializer {
private static final Logger logger = Logger.getLogger(WebAppInitializer.class);
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
// Create the root appcontext
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(AppConfig.class);
servletContext.addListener(new WebAppRootListener());
// Manage the lifecycle of the root appcontext
servletContext.addListener(new ContextLoaderListener(rootContext));
//servletContext.setInitParameter("defaultHtmlEscape", "true");
// The main Spring MVC servlet.
ServletRegistration.Dynamic springapp = servletContext.addServlet(
"springapp", new DispatcherServlet(rootContext));
springapp.setLoadOnStartup(1);
Set<String> mappingConflicts = springapp.addMapping("/");
...etc...
Thanks to anyone who can offer advice!