Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting request attributes in freemarker

Tags:

freemarker

How do I check a value from the request attribute in freemarker? I tried <#if *${RequestParameters['servicesettings']} ??> but getting errors ->

Encountered "*" at line

Can anyone help?

like image 358
zDroid Avatar asked Sep 21 '11 12:09

zDroid


Video Answer


2 Answers

It depends on the Web application framework, because FreeMarker itself doesn't expose the request parameters. (Well, except if the framework uses freemareker.ext.servlet.FreemarkerServlet which is kind of an extension to FreeMarker.) Also, usually you shouldn't access request parameters directly from an MVC template, or anything that is HTTP/Servlet specific.

As of the error message, what you have written has a few syntax errors... probably you meant <#if RequestParameters.servicesettings??> (it's not JSP - don't use ${...}-s inside FreeMarker tags). This will require that you have RequestParameters in the data-model, that I can't know for sure...

like image 128
ddekany Avatar answered Oct 12 '22 11:10

ddekany


We should write like this:

${Request.requestattribute}
like image 23
praveen Avatar answered Oct 12 '22 11:10

praveen