This GSP:
<g:link controller="book" action="show" id="5">Example</g:link>
leads to the following HTML:
<a href="/book/show/5">Example</a>
This applies to the HTTP host. If your site runs on http: // localhost: 8080 , that’s fine.
During development, the application will run more often on http: // localhost: 8080 / appName .
In such cases, the above link will not work - this will lead to an absolute URL http: // localhost: 8080 / book / show / 5 instead of the required http: // localhost: 8080 / appName / book / show / 5
What changes are needed for the above GSP for the name of the application that should be present in the received href application?
grails.app.context , , . , , , http://localhost:8080/appName. (, http://locahost:8080/), Config.groovy:
grails.app.context
http://localhost:8080/appName
http://locahost:8080/
Config.groovy
grails.app.context = "/"
, URL-, g:link, .
g:link
, meta GSP.
meta
, , :
<g:meta name="app.name"/>
application.properties, .
application.properties
, , , . , g:. :
g:
<g:set var="help" value="http://localhost:8080/${meta(name:"app.name")}/help" />
Grails , .
<g:link> , , , , http://localhost:8080 prod http://mycoolsite.com - .
<g:link>
g:resource css, javascript .. - GSP, (, "appName" ), .
g:resource
I think grails.serverURL is needed for this. You defined this configuration variable in Config.groovy, for more information see the configuration documentation for Grails .
Hope this helps!
In the createLink tag, your appname / context parameter is automatically included.
Here is the doc link for it.
Source: https://habr.com/ru/post/1793686/More articles:ASP.NET 2.0 application never loads - asp.netLucene Term Vector Multivariate Bayes Model Waiting Maximization - luceneRegex matches ini value - javascriptC # Reading a byte array - c #C # shared memory between managed and unmanaged code - c #ActiveX component cannot create object - windows-7Preventing other programs from executing - linuxHow can you find out if the Sql Server stored procedure returns records - tsqlMongoose, Cygwin, and MongoDB - Not Saved - node.jsHttpListeners and ports - c #All Articles