grails 2.0 - correct use of serverURL for production?

后端 未结 2 1393
后悔当初
后悔当初 2021-02-04 02:27

Grails 2.0 changed with the way it uses grails.serverURL for development and test environments (as described in the manual). However, I\'ve had several problems with serverURL

2条回答
  •  生来不讨喜
    2021-02-04 03:14

    So the basic idea of the grails.serverURL configuration parameter is to allow the createLink method to know what URL you want when creating absolute links. If no grails.serverURL configuration parameter is specified, it will default to http://localhost:8080 (unless server.port is specified, then 8080 will be whatever) ...

    The application context tells Jetty/Tomcat to run the application in a different root. For example, specifying

    grails.app.context="/myApp"
    

    will set your application root to "/myApp". In production mode, the application context is handled by the web container and this directive is ignored. The choice to configure your production jetty or tomcat instances to run your application in a different context is entirely dependent on what your technical requirements are.

    So the real thing to consider is, in your application are you creating a lot of absolute links in your GSPs where you need to define a "production" serverURL? If not, then you don't need to specify it; if you are, then you'll need to specify it.

    As a personal preference, the first thing that I always do after creating a new grails project is go into the config and change the grails.app.context to "/" ... It makes mirroring a production environment much easier for me.

    Hope this clears things up!

提交回复
热议问题