2013-03-07 106 views
-1

我可以叫控制器關閉使用以下鏈接GSP視圖:remoteLink找不到控制器

<g:link url="${request.contextPath}/data/${params.name}/myController/myClosure"> 
Text Goes Here 
</g:link> 

不過,我想用remoteLink,因爲我不想渲染什麼,只是執行一項任務。我是否想使用remoteLink正確?

不幸的是,remoteLink沒有url屬性。所以我用的控制器和動作:

<g:remoteLink controller="myController" action="myClosure"> 
Text Goes Here 
</g:remoteLink> 

不成功地使用URL 「/對myApp/myController的/ MyClosure」,這是從作品的網址不同。

所以我的問題是,

  1. 怎麼我的控制器獲得更長的網址?它沒有出現在我的URLMappings中。什麼控制這個?

  2. 是否有反正我可以使用remoteLink來訪問該網址?

謝謝!

回答

0

URL映射必須命名爲:

static mappings = { 
    name <mapping name>: <url pattern> { 
     // … 
    } 
} 

然後,你可以這樣做:

<g:remoteLink mapping="<mapping name>" controller="myController" action="myClosure"> 
Text Goes Here 
</g:remoteLink>