我有一个webapp,它将main.gsp定义为所有视图中使用的默认布局,我正在使用spring-mobile插件在移动视图和桌面视图之间切换。但我现在想为移动用户在mobile.gsp布局和main.gsp布局之间切换。
做这件事最好的方法是什么?
发布于 2012-07-23 09:01:25
由于您使用的是Spring Mobile,因此可以使用过滤器来拦截控制器调用并设置布局:
class MobileFilters {
def filters = {
mobileFilter(controller:'*', action:'*') {
afterView = {
def layout = "main"
withMobileDevice {
layout = "mobile"
}
session.layout = layout
}
}
}
}然后在你的gsps中
<meta name="layout" content="${session.layout}">https://stackoverflow.com/questions/11598075
复制相似问题