<g:if test="${!request?.xhr}">
<!doctype html>
<html>
<head>
<meta name="layout" content="home">
</head>
<body>
<div class="row-fluid">
</g:if>
AJAX
<g:if test="${!request?.xhr}">
</div>
</body>
</html>
</g:if>
我收到错误消息:
Grails tag [sitemesh:captureBody] was not closed.
在
Config.groovy中,我设置了
grails.views.gsp.sitemesh.preprocess = false,但这无济于事。
用if语句使用部分 View 的方式。
请您参考如下方法:
处理此问题的更好方法是包装包含主要内容的模板。例如:
//_body.gsp
AJAX
//view.gsp
<!doctype html>
<html>
<head>
<meta name="layout" content="home">
</head>
<body>
<div class="row-fluid">
<g:render template="body">
</div>
</body>
</html>
然后,您的 Controller 可以在常规请求上呈现整个 View ,或者仅在AJAX上呈现正文。




