Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用允许的方法从grails中的grails链接中删除一行_Grails_Grails 2.0 - Fatal编程技术网

使用允许的方法从grails中的grails链接中删除一行

使用允许的方法从grails中的grails链接中删除一行,grails,grails-2.0,Grails,Grails 2.0,我正在使用Grails2.4.2。我有一个表格,可以在其中添加、编辑或删除任何数据或行。但从索引中,我想根据需要删除一行。为此,我在表格单元格中为每一行添加了一个链接。但它给出了错误405,即请求的资源不允许使用指定的HTTP方法。有人能帮我吗?以下是我的索引页: 我的索引.gsp>>> <table> <thead> <tr> &l

我正在使用Grails2.4.2。我有一个表格,可以在其中添加、编辑或删除任何数据或行。但从索引中,我想根据需要删除一行。为此,我在表格单元格中为每一行添加了一个链接。但它给出了错误405,即请求的资源不允许使用指定的HTTP方法。有人能帮我吗?以下是我的索引页:

我的索引.gsp>>>

<table>
        <thead>
                <tr>                    
                    <g:sortableColumn property="address" title="${message(code: 'userInfo.address.label', default: 'Address')}" />                  
                    <g:sortableColumn property="name" title="${message(code: 'userInfo.name.label', default: 'Name')}" />
                    <g:sortableColumn property="name" title="${message(code: 'userInfo.name.label', default: 'Action')}" />
                </tr>
            </thead>
            <tbody>
            <g:each in="${userInfoInstanceList}" status="i" var="userInfoInstance">
                <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">                   
                    <td><g:link action="show" id="${userInfoInstance.id}">${fieldValue(bean: userInfoInstance, field: "address")}</g:link></td>                 
                    <td>${fieldValue(bean: userInfoInstance, field: "name")}</td>
                    <td><g:link action="delete" id="${userInfoInstance.id}">Delete</g:link></td>                    
                </tr>
            </g:each>
            </tbody>
        </table>

${fieldValue(bean:userInfoInstance,字段:“address”)}
${fieldValue(bean:userInfoInstance,字段:“name”)}
删除

我认为您正在控制器中使用“allowedMethods”,如下所示

    static allowedMethods = [delete: "POST"]


但是,当您使用链接标记库时,您是在发出GET请求,而不是POST

谢谢您的回复。我允许的方法如下
static allowedMethods=[save:“POST”,update:“PUT”,delete:“delete”]
。我的问题是,我可以使用delete:delete和g:link标签吗?!!!不,你不能。您必须使用AJAX,或者需要使用DELETE方法提交表单