我注意到一些奇怪的行爲redirect
當我設置我的app.context
某種方式。我發現,在Grails的JIRA這恰如其分地描述了我的問題的錯誤,但它被標記爲UTR:http://jira.grails.org/browse/GRAILS-7546使用app.context時,Grails會重定向到錯誤的地址?
這裏是我的問題描述:
我目前使用的Grails 2.0M2。我在application.properties定義了以下屬性文件:
app.context=/
app.name=foobar
當我打電話redirect
在控制器,redirect
是增加了應用程序的名稱到URI我提供,然後導致404.這是如何我「M這樣做:
String partialUrl = createLink(mapping: 'helloworld') // returns `/hello/world`
redirect(uri: partialUrl) // INCORRECTLY redirects to
// `http://mysite.com/foobar/hello/world`
// instead of `http://mysite.com/hello/world`
假設我在我的UrlMappings.groovy
文件中定義了一個名爲helloworld
URL映射爲/hello/world
的路徑。
所以,長話短說,如果我設置app.context
到/
,我會不預計app.name
在我最後重定向URL露面。
這是一個錯誤或預期的行爲?任何想法,我可以建立重定向的URL最簡單的方式,而不需要做太多的手動步驟?
正確... Tomcat可能會在生產中覆蓋app.context,但問題仍然是'重定向',即在構建重定向URL而不是使用app.context時,Grails正在使用app.name。 – Polaris878