NutzCN Logo
问答 使用beetl,怎么根据不同的参数进入不同的页面
发布于 2270天前 作者 qq_75eaf26a 2124 次浏览 复制 上一个帖子 下一个帖子
标签:

要做一个门户的后台管理系统,现在使用的是beetl,我想前台显示的时候可以根据选择调用不同的模板,比如列表页面有3个模板,我选择的a.html 我渲染的时候用a.html,选择b模板的时候用b.html这个该怎么做?即@ok返回的不是固定地址,根据参数来的!

12 回复

你确定是模板不同? 一般是css路径不同呢

确定是模板不同啊,比如一个门户列表页的样式有很几种 我可以根据传过来的模板list0去找list0.html ,list1去找list1.html,主要还是想增加灵活性

@Ok里面也支持EL表达式

@Ok("beetl:xxx/xxxx/${req_attr.XXX}/index.html")

@GetMapping("/${system.site.prefix}/{siteId}/{categoryId}")
public String category(@PathVariable("siteId") Integer siteId,
@PathVariable("categoryId") Long categoryId,
Model model){
log.debug("栏目");
TCmsSite site = siteService.findById(siteId);
if(CmsUtil.isNullOrEmpty(site))
throw new CmsException(CmsConst.SITE_NOT_FOUND);
TCmsCategory category = categoryService.findById(categoryId);
if(CmsUtil.isNullOrEmpty(category))
throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
PageInfo page = contentService.page(1,siteId,category.getCategoryId());
model.addAttribute("title",category.getCategoryName());
model.addAttribute("keyword",site.getKeyword());
model.addAttribute("description",site.getDescription());
model.addAttribute("site",site);
model.addAttribute("category",category);
model.addAttribute("page",page);
if(StrUtil.isBlank(site.getTemplate()))
return view(category.getIndexTpl());
String viewName = view((ControllerUtil.isMobile()&&site.getIsMobile())?site.getMobileTpl():site.getTemplate(),category.getIndexTpl());
System.out.println(viewName);
return view((ControllerUtil.isMobile()&&site.getIsMobile())?site.getMobileTpl():site.getTemplate(),category.getIndexTpl());
}


private String view(String theme,String viewName){
return "www/"+theme.trim()+"/"+viewName.trim();
}

```
类似于这种代码 我不不知道他是怎么做到找不同模板的

GetMapping 不是nutz mvc的东西

上面是spring的写法。

相当于@Ok("re")的用法

然后我想问下在nutz这种怎么写。打印出的viewName = www/blog/list 对应的就是模板的list.html,

喔 是re的用法 我试试 谢谢叫兽了,这个回复为啥没有上传图片的功能。其实图片更直观。

每次开放传图,都有人乱传图, 而且图片无法索引

添加回复
请先登陆
回到顶部