1
我正在将一个Web应用程序迁移到Spring 3.2,并享受无需配置web.xml的配置。设置webapprootkey no-web.xml
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapproot</param-value>
</context-param>
我知道,春天创建一个默认的关键,但对我来说我跑的多个版本:即剩余的设置Web应用程序根密钥,这是我以前在web.xml中没有像这样 一部分同样的战争,需要在每个战争中设置一个不同的值。所以我最好从属性文件中获取一个值并将其用作rootkey。
我想,我会在这里做到这一点的地方:
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...
由于任何人谁可以提供建议!
你可以分享是在application.properties中,我有一个场景,其中运行两个webapps,这是从同一个maven快速入门创建的,如果在服务器上的smae时间添加这两个应用程序会导致问题。这是我的问题:http://stackoverflow.com/q/18543317/1654823,你可以看看 – Venkat