Freemarker method cannot accept object as parameters

I am trying to pass Freemarker HashLiteral to my custom method as follows:

<a href="${href("Item", {"item": item})}">...</a>

where item without quotes is an object given in ModelAndView. The {“item”: item} is correctly transformed to freemarker.core.HashLiteral$SequenceHash, but I cannot recover it in my method as I get following exception:

Expecting a string, date or number here, 
   Expression {"item": item} is instead a freemarker.core.HashLiteral$SequenceHash

This happens even with href method having empty body:

public TemplateModel exec(List args) throws TemplateModelException {
    return new SimpleScalar("");


It’s probably that href is a TemplateMethodModel instead of a TemplateMethodModelEx. The args argument in TemplateMethodModel.exec(args) is a List of String-s, hence FreeMarker tries to convert the value to a string, but it can only do that with string, date or number values. So just change it to TemplateMethodModelEx and then args will be a List of TemplateModel-s and hence accepts all kind of values.