如何修改GGTS中与Tomcat相关的更改

时间:2014-04-23 21:02:42

标签: xml eclipse tomcat grails groovy

我有一个grails app项目并通过GGTS中的run-app命令运行它。我想更改GGTS / grails使用的内置Tomcat的context.xml。

例如,我想添加sessionCookiePath =" /"到context.xml进行会话共享。我无法找到xml文件的位置。我检查了与Tomcat相关的文件夹(在.grails下),但是我找不到与Tomcat相关的文件。

有没有办法添加sessionCookiePath =" /"通过app项目的Config.groovy ??或者我可以访问内置tomcat的实际context.xml吗?或者我应该采取完全不同的方法??

1 个答案:

答案 0 :(得分:0)

基本上我使用了tim_yates建议的链接,并且能够配置sessionCookiePath。如果有人在寻找设置sessionCookiePath的答案,请使用此。

  1. 在grails项目下 - > scripts-> _Events.groovy(如果没有,则创建_Events.groovy)
  2. 添加如下所示的eventConfigureTomcat

    eventConfigureTomcat = {tomcat ->
     if (GrailsUtil.environment == 'development')
     {
        def ctx=tomcat.host.findChild(serverContextPath) // serverContextPath is auto injected or you can use the actual server context for e.g., "/app1"
        ctx.sessionCookiePath = '/'
     }
    }