i want create ajax-navigation on site freemarker
template engine. if page requested xmlhttprequest
, there no need include page header , footer. code this:
[#if !xmlhttprequest] [#include "header.ftl"] [/#if] ${content} [#if !xmlhttprequest] [#include "footer.ftl"] [/#if]
my question how define request came ajax. client adds header x-requested-with: xmlhttprequest, , how in freemarker? tried find in httprequesthashmodel:
[#assign xmlhttprequest = request.headers['x-requested-with']=="xmlhttprequest" /]
but throws error expression request.headers undefined
. tried use requestparameters can't too.
freemarker doesn't define http related variables; it's not jsp, it's general purpose engine; sees variables passed it, , doesn't know are... name-value pairs far freemarker concerned. if need information, either should pass freemarker in actions (maybe globally filter or interceptor or whatever have), or web application framework should.
Comments
Post a Comment