I want to get bean values in my freemaker tempalate. For that what i am doing is ?
In my java class :
MyBean myBean= new MyBean();
myBean.setName("ranveer");
session.setAttribute("MyBean", myBean);
I also created the setter and getter.
In tempalate when i am doing this :
<#assign bean= Session.MyBean>
${bean}
It is printing my class package name but when i am doing this in tempalate :
<#assign bean= Session.MyBean>
${bean.name}
Name is the property that i have defined in my bean and value is ranveer but its not printing this value. The StackTrace is :
The Web Script /Test/service/inbox/sidebar has responded with a status of 500 - Internal Error.
500 Description: An error inside the HTTP server which prevented it from fulfilling the request.
Message: 09310010 Failed to process template webscripts/inbox/inbox.sidebar.get.html.ftl
Exception: freemarker.core.InvalidReferenceException - Expression ${bean.name} is undefined on line 5, column 11 in webscripts/inbox/inbox.sidebar.get.html.ftl.
freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
freemarker.core.Expression.getStringValue(Expression.java:118)
freemarker.core.Expression.getStringValue(Expression.java:93)
freemarker.core.DollarVariable.accept(DollarVariable.java:76)
freemarker.core.Environment.visit(Environment.java:208)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:208)
freemarker.core.Environment.process(Environment.java:188)
freemarker.template.Template.process(Template.java:237)
org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:156)
org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:580)
org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:263)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:143)
org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)
org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:203)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)