我有一个问题,动态地更改grails 3 Web应用程序的contextPath。它的工作,如果我在groovy.gsp(server.contextPath = “/对myApp”)改变它,但我需要有这样的不同的名字部署:Grails 3,动态更改contextPath(servletContext?)
myApp_A.war => IP:端口/ myApp_A myApp_B。 war => IP:Port/myApp_B
可以获取直接名称(llike:myApp_A.war的“myApp_A”)并动态读取正确的属性文件(myApp_A.properties)。之后,我试图设置此实例的上下文路径动态为IP:端口/ myApp_A
我试图改变grails“server.contextPath”的引导如下: Holders.config.'server。 contextPath'='/ myApp_A' 但是这并不完整。在这种情况下,我将被重定向到IP:Port/myApp_A,但后来我得到了404。web服务仍在监听静态配置(“/ myApp”)。
我想我必须在早些时候改变它(在bootstrap中已经太晚了),或者直接在servletContext中改变它。将Holders.config.'server.contextPath'更改为新路径后,servletContext仍包含旧的静态路径(servletContext.getContextPath()=旧路径)。
In: class Application extends GrailsAutoConfiguration implements EnvironmentAware {... 我可以读取我的设置并在创建servletContext之前注入它们。任何想法如何在那里设置contextPath?
问候, grailsfan
这是工作,很棒!谢谢!! – user3635450