How can I tell if a certain view (tile) has been defined in a Controller?
Spring 3.0.5 + Tiles
Inside my controller I'm creating a new ModelAndView but a situation has come up where one company wants their own view. Once this happens I can see this growing where other's want their own as well.
@RequestMapping(params="companyId")
public ModelAndView newCompanyView(HttpServletRequest request, String companyId) {
// right here I'd like to check if the "companyABC" view is a defined tile
// and if it is the send that back as a view and I can eliminate a bunch of if
// checks.
if(companyId.equals("ABC")) {
return new ModelAndView("companyABC", "vo", getCompan开发者_C百科yVo());
} else {
return new ModelAndView("company", "vo", getCompanyVo());
}
}
Is this possible and if so then how?
I think you might be interested in Spring's support for themes, which can inherit from each other and fallback to a default.
Apparently there really isn't a good way to do this unless you really want to dive head first into fiddling with view resolvers. I don't have the time or the desire to try and figure it out but if someone smarter than I has some time I'd love to hear a solution. Until then I'm just going to punt and have some IF checks for special companies.
精彩评论