Grails index.gsp将action视为视图并抛出错误

时间:2016-01-28 02:26:45

标签: grails

My Grails index.gsp(域类的视图)引发错误500:"Could not resolve view with name '/someClass/auth' in servlet with name 'grailsDispatcherServlet' "

我在我的控制器中定义了一个空动作def auth={},除了文本字段和g:form动作auth

按钮之外什么都没有

/user/index.gsp:

<!DOCTYPE html>
<html>
    <head>
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'someClass.label', default: 'SomeClass')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
    <g:form action="auth">
        <a href="#list-someClass" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
        <div class="nav" role="navigation">
            <ul>
                <li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
                <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
            </ul>
        </div>
            <g:if test="${flash.message}">
                <div class="message" role="status">${flash.message}</div>
            </g:if>
            <input type="submit" value="login"/>

        </g:form>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

假设gsp在/user/index.gsp中,按照惯例,grails期望UserController和一个名为auth的方法。如果auth方法位于不同的控制器中,请确保在g:form的控制器属性中添加名称

<g:form controller="<controller-name>" action="auth">