Web アプリを Spring 3.2 に移行していて、web.xml を使用しない構成を楽しんでいます。残っている部分の 1 つは、以前に web.xml で次のように行った webapp ルート キーの設定です。
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapproot</param-value>
</context-param>
Spring がデフォルトのキーを作成することは知っていますが、私の場合、同じ war の複数のバージョンを実行しており、それぞれでキーを異なる値に設定する必要があります。したがって、最適には、プロパティ ファイルから値を取得し、それをルートキーとして使用したいと考えています。
ここのどこかでこれを行うと思います:
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...
アドバイスを提供できる人に感謝します!