我想知道grails中面包屑的用法和实现。
我有一些gsp(view)页面,主页是默认页面,我有6个类别,在那6个子页面中,我需要在我的页面中显示导航路径,例如
家庭/杂货/杂货店...
家庭/财务/次级财务...
我需要显示页面导航。
<div id="heder_content">
<g:if test="${session.user }">
<div id="bread_crumbs"style="position:absolute;top:0px;left:474px;height:80px;width:800px">
</div>
</div>
</g:if>
最佳答案
您想实现什么目标?您可以尝试创建一个taglib,在其中读取 Controller 名称和操作,并传递一些参数来显示产品名称。
我的意思是这样的:
<g:breadcrumb title="${product.name}" />
并在您的taglib文件中:
class BreadCrumbTagLib {
def breadcrumb = { attrs ->
def title=attrs.remove('title')
out << '''<div id="bread_crumbs"style="position:absolute;top:0px;left:474px;height:80px;width:800px">${controllerName} / ${actionName} / ${title} </div>'''
}
}
我的例子很简单,但是希望您能理解!如果您需要更复杂的东西,建议您看一下:http://adityakalia.wordpress.com/2011/01/10/breadcrumbs-framework-for-grails/
关于grails - 面包屑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16620625/