Sending request params to Freemarker templates (from SPring) ,getting InvalidReference exception
From Spring Controller i am sending some request paramters to be fetched in FTL and be displayed. But somehow i am landing into InvalidReference Exception. I am totally new to FTL but i know this doesnt require much setup from spring either.
All other ftls receving request param开发者_运维技巧s work but this ftl(searchPage) has only 1 requestParam used .
In Spring Controller Method:
@RequestMapping("/searchPage")
public String SearchMethod(@RequestParam String x,@RequestParam(required=false) String op,MapModel m)
{
int myCount=Method_call_returns_int();.
m.addAttribute("Count", myCount);
return "searchPg";
}
In FTL ,i import spring.ftl and use ${count!} or ${count} -to fetch dynamic value from controller.
1. Exclamation mark -"!" i believe is not-null expression in freemarker. Somehow count is come to be 'null' in FTL ${count} -doesnt throw or display any exception because of ! ${count!} throws InvalidReferenceExc .
Please correct me here if i misunderstood meaning of !.
2.I debugged java code and see that ModelMap has count added correctly but its only in FTL that not receiving it.
I din't do any other setup explicitly and i dont think its required.
I see other FTLs with similar cases working ,only difference is Object (in my case its int).
Please suggest me what could be the reason .
I believe freemarker is case-sensitive and hence Count
would not be the same as count
Hi all Thanks for your replies.Realized it was my mistake caling method at wrong place.Freemarker doesnt need any setup or initialization.
精彩评论