English 中文(简体)
商标名称“变数”可能含有 da子。
原标题:Freemarker ".vars" names can t contain dashes?
  • 时间:2011-06-09 23:30:11
  •  标签:
  • freemarker

我们使用自由标识版本2.3.16,我刚刚在我们的一张 app子中 track下了。 当时,我们的一些产品编码中出现了hy。 这些代码用于利用<代码>.vars将地方化案文的斜体从全球范围拉开。

减少这一问题给我一个榜样,任何人都可以尝试:

  • 0。

这三个方面都应引起例外。 相反,它出现在<代码>.vars参数说明正在评估之中!

http://freemarker.sourceforge.net/docs/app_faq.html#faq_strange_variable_name 这意味着这项工作应当奏效。

几周前,我看到在《自由声明》邮寄名单上提到类似问题,建议先确定“@”的参数。 这可能与其他海螺合作,但NOT与.vars合作。 我仅举一个工作例子(.vars[“resources_title”][),并改写成“InvalidReferenceException”(.vars["@resources_title”][)。 我也用手提的字眼对它进行了审判,并且也提出了例外。

升至2.3.18似乎没有改变。

最佳回答

Works for me. And like already mentioned on the freemarker-user mailing list: maybe you use a strange data model, or even a fancy ObjectWrapper. But a discussion like this is probably better suited for the freemarker-user mailing list...

问题回答

Sorry for the delay. After some good mailing-list help on places to put breakpoints, here s I wrote back to the list on June 10th:


Short story: It s not a Freemarker issue. Rather the Struts team chose to hard-wire Freemarker to treat .vars names as OGNL expressions, and there seems no way to tell OGNL to not parse them. So under Struts, "-" and "+" (and possibly other characters) cannot appear in .vars names.

Long story...

  • freemarker.core.BuiltinVariable (line 192) is where Freemarker starts to process .vars expressions

  • freemarker.core.Environment (line 1088) Hand control over to the “rootDataModel”,Stuts小组硬通布,作为org.apache.struts2.views.freemarker.ScopesHashModel

  • 该类别的第70条(使用《Stuts》第2.1.8.1版)称“stack.findValue”;“stack”被电为com. opensymphony.xwork2.ognl.OgnlValueStack

  • 在第236行,这几类人反过来要求有<条码>OgnlUtil来找到标的,而名称被假定为OGNL的表达和教义,将“foo-bar”变成(oo-条)。

任何时候似乎都选择NOT处理.vars。 姓名作为表达方式(FreemarkerResult的评论,可能的话,但该守则没有通过。 在理论上,我可以实施<代码>FreemarkerManager,从而形成一个<代码>ScopesHashModel的备选案文,但这将需要大量的工作来改变与之相关的所有类别。

(Nor似乎没有办法逃脱OGNL表示的“-”特性。) 见5-6年前曾讨论过这一问题,但.... .vars (“foo/-bar” 在“......”之后发现“-”被认为“-”无能力?)

:

I m 不清楚处理<代码>的使用情况。 姓名作为表达方式......但我不会想到现在会有变化。 我不是凌驾于几十个Stuts级,而是改变了把我们的资源Bundles装入价值等级的代码:现在改用“-”和“_”的名称,同样改用我的<代码>。 模板和......拖拉机对名称作了同样的改动。 它行之有效。 Woo。

It works if it added with escape foo-bar. "Only single backslash"





相关问题
Can a freemarker viewpage be user editable and secured?

If I let anyone modify a freemarker viewpage, can I somehow make it hack free? I know I read somewhere that I can make disable scriplets, but that was for .jsp pages so not sure if it will work with ...

can freemarker be used to output custom collections?

Can freemarker be used to loop through collections and output the properties of each item in the collection? This collections properties will be dynamic i.e. can t be hard coded, will be generated ...

one template to several output files with fmpp

I want to set up an maven plugin that will take a few freemarker templates, and expand each one several times, each time with a different set of input values. Is there any better way to do this with ...

Nullable date in Freemarker

This is a piece of my freemarker template: ${order.needByDate?if_exists?date} I want it to work as following: if needByDate is null, then write nothing if it is not null, then write the date part ...

Freemarker template not found

I m currently trying to get Freemarker to work with my application using Spring. No matter what I try I keep getting template not found. I am not sure if I have the configuration set up properly, ...

Spring Security Custom freemarker form

I m currently working on a project were we use freemarker as a template language. Instead of using the defualt login form I have created a custom controller and a custom freemarker view which goes ...

热门标签