0

我有一个带有多个页面和控制器的 grails 应用程序。虽然某些操作正常工作并且 gsp 页面正确呈现,但由于某些与 CGLIB 相关的错误,其中一些操作未呈现。这是我想运行 /panel/create 操作时的异常:

processing request: [GET] /panel/create
Template not found for name [form] and path [/panelController$$EnhancerByCGLIB/_form.gsp]. Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error proc                                                                                                                                                             essing GroovyPageView: Template not found for name [form] and path [/panelContro                                                                                                                                                             ller$$EnhancerByCGLIB/_form.gsp]
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(Pag                                                                                                                                                             eFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter                                                                                                                                                             .java:63)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.                                                                                                                                                             java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor                                                                                                                                                             .java:615)
    at java.lang.Thread.run(Thread.java:722)

_form.gsp:

<div class="fieldcontain ${hasErrors(bean: panelInstance, field: 'unitProtocol', 'error')} required">
<label for="unitProtocol">
    <g:message code="panel.checkupPanel.label" />
    <span class="required-indicator">*</span>
</label>

<g:if test="${panelInstance?.unitProtocol}">
    <g:select id="unitProtocol" name="unitProtocolId" from="${unitProtocolService.getNonDefinedCheckUpPanelUnitProtocols() + panelInstance?.unitProtocol }" optionKey="code" value="${panelInstance?.unitProtocol?.code}" class="many-to-one"/>
</g:if>
<g:else>
    <g:select id="unitProtocol" name="unitProtocolId" from="${unitProtocolService.getNonDefinedCheckUpPanelUnitProtocols()}" optionKey="code" value="${panelInstance?.unitProtocol?.code}" class="many-to-one"/>
</g:else>
</div>
        <div class="fieldcontain panelGrid grid">
            <table id="panelGrid"></table>
        </div>

        <div id="panelPager"></div>

<script type="text/javascript" src="${resource(dir: 'js', file: 'panel.js')}"></script>

创建.gsp

<%@ page import="akum.main.pricingcontract.Panel" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main">
    <g:set var="entityName" value="${message(code: 'panel.label', default: 'Panel')}" />
    <title><g:message code="default.create.label" args="[entityName]" /></title>
</head>
<body>
    <div id="create-panel" class="content scaffold-create" role="main">
        <h1><g:message code="default.create.label" args="[entityName]" /></h1>
        <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
        </g:if>
        <g:hasErrors bean="${panelInstance}">
        <ul class="errors" role="alert">
            <g:eachError bean="${panelInstance}" var="error">
            <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
            </g:eachError>
        </ul>
        </g:hasErrors>
        <g:form action="save" >
            <fieldset class="form">
                <g:render template="form"/>
            </fieldset>
            <fieldset class="buttons">
                <g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
            </fieldset>
        </g:form>
    </div>
</body>

面板控制器:

package akum.main.pricingcontract

import javax.persistence.Transient;

import grails.converters.JSON

import org.springframework.dao.DataIntegrityViolationException
import org.springframework.transaction.annotation.Transactional;

class PanelController {

def fpProviderService
def unitProtocolService

static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

def index() {
    redirect(action: "list", params: params)
}

def list(Integer max) {
    params.max = Math.min(max ?: 10, 100)
    removeSessionParameters()
    [panelInstanceList: Panel.list(params), panelInstanceTotal: Panel.count()]
}

def create() {
    session.activePanelOperation = "create"
    [panelInstance: new Panel(params)]
}
}

这些视图是使用 grails 脚手架创建的,只涉及很少的业务。

我的 Grails 版本是 2.1.1。

4

1 回答 1

0

结果是我的控制器上的@Transactional 注释保存方法。当我删除它们时,我解决了这个问题。

于 2013-07-30T06:19:03.480 回答