代码如下 siteService,contentService在其他模块都能用,就是在这个里面都为空,访问的时候可以访问的到。。。,没看出来和其他controller有啥区别。包也是在正确的位置。
@IocBean
@At("/front")
public class IndexController extends AbstractController{
private static final Log log = Logs.get();
@Inject
private SiteService siteService;
@Inject
ContentService contentService;
@Inject
CategoryService categoryService;
/**
* 访问路径/front/dfc1c893a62842f69dfb74b5199275a6/f710084833084f13918f4e5f7c66c1e2
* @param siteId
* @param categoryId
* @return
*/
@At({"/?/?","/"})
@Ok("re")
public String category(@Param("siteId") String siteId, @Param("categoryId") String categoryId,HttpServletRequest request) {
log.debug("栏目");
CmsSite site = siteService.findById(siteId);
if (site==null)
throw new CmsException("站点未找到!");
CmsCategory category = categoryService.fetch(categoryId);
if (Lang.isEmpty(category))
throw new CmsException("栏目未找到!");
Cnd cnd = Cnd.where("siteId", "=", siteId).
and("categoryId", "=", categoryId);
Page<CmsContent> page = contentService.listPage(1, cnd);
request.setAttribute("title", category.getName());
request.setAttribute("keyword", site.getKeyword());
request.setAttribute("description", site.getDescription());
request.setAttribute("site", site);
request.setAttribute("category", category);
request.setAttribute("page", category);
return view( site.getTemplate(),category.getIndexTpl());
}
private String view(String theme,String viewName){
return "www/"+theme.trim()+"/"+viewName.trim();
}
}