我注意到,一些應用程序我測試有另一種觀點認爲,從動作控制器提交,但是當該頁面呈現的/,而不是看到來電:
$控制器/ $頁
我看到:
$控制器/指數
這是與URL映射配置的問題?默認操作?只是好奇,因爲它似乎是映射到默認的URI而不是實際的操作。
視圖代碼:
<table>
..
<g:actionSubmit class="stats" action="stats" value="View Stats"/>
..
</table
控制器:
def stats() {
def teamId = Team.get(params.id)
def allPlayers = Player.withCriteria {
eq('team', teamId)
and {
eq('isActive', true)
}
}
[allPlayers:allPlayers, teamId:params.id]
}
urlMapping中:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
}
編輯
我實際他想出了它是什麼。這讓我更加困惑。
grails actionSubmit有一個綁定它的動作。這種形式只是一個正常的形式,沒有電話:
<g:form>
<g:actionSubmit class="stats" action="stats" value="View Stats"/>
<g:actionSubmit class="schedule" action="schedule" value="View Schedule"/>
<g:form>
所以默認情況下,形式重定向動作$控制器/索引。如果您在g:form標籤中添加一個動作調用,那麼這兩個按鈕將直接指向正確的頁面,但是現在URI將變爲$ controller/$ g:form_action。
我想我不明白actionSubmit的動作,如果需要g:form作爲包裝。
http://jira.grails.org/browse/GRAILS-3086 – user82302124 2012-04-19 15:05:17