Error On Line 5 Column 20 In Template/simple/head.ftl
This Site Careers Other all forums Forum: Struts FreeMarker template error pankaj semwal Ranch Hand Posts: 303 posted 7 years ago Hi, I am getting following error and i am using Strut2. Dont know what is causing this, any help will be appreciated. Expression error is undefined on line 35, column 4 in template/simple/actionerror.ftl. The problematic instruction: ---------- ==> ${error} [on line 35, column 2 in template/simple/actionerror.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression error is undefined on line 35, column 4 in template/simple/actionerror.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.Expression.getStringValue(Expression.java:118) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160) at freemarker.core.Environment.visit(Environment.java:351) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.Environment.process(Environment.java:176) at freemarker.template.Template.process(Template.java:232) at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:168) at org.apache.struts2.components.UIBean.mer
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting https://coderanch.com/t/454998/Struts/framework/FreeMarker-template-error “Freemarker template Error” while using <@s.generator and iterator tags up vote 1 down vote favorite I am learning Struts 2. While creating views using FreeMarker template, I am getting an error. I am using Eclipse IDE and running the application in Tomcat 8. Freemarker Code:
Sample...(FreeMarker)
<@s.iterator> <@s.property />
@s.iterator> @s.generator> Eclipse Console Trace Log: > Jul 14, 2016 8:19:02 PM > com.opensymphony.xwork2.util.logging.jdk.JdkLogger error SEVERE: > Exception occurred during processing request: The following has > evaluated to null or missing: > ==> s.generator [in template "WEB-INF/content/enter-protein.ftl" at line 10, column 11] > > ---- Tip: It's the step after the last dot that caused this error, not those before it. > ---- Tip: If the failing expression is known to be legally refer to something that's null or missing, either specify a default value like > myOptionalVar!myDefault, or use <#if > myOptionalVar??>when-present<#else>when-missing#if>. (These only > cover the last step of the expression; to cover the whole expression, > use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? > ---- > > ---- FTL stack trace ("~" means nesting-related): > - Failed at: @s.generator separator="," val="%{'15... [in template "WEB-INF/content/enter-protein.ftl" at line 16, column 9] > ---- FreeMarker template error: The following has evaluated to null or missing: > ==> s.generator [in template "WEB-INF/content/enter-protein.ftl" at line 16, column 11] > > ---- Tip: It's the step after the last dot that caused this error, not those
struts 2.0.7 template/simple/select.ftl error/fix-------------------------------------------------Key: WW-1887URL: https://issues.apache.org/struts/browse/WW-1887Project: Struts 2Issue Type: BugReporter: Jason ThurstonTo http://grokbase.com/t/struts/issues/074htjjx5v/jira-created-ww-1887-struts-2-0-7-template-simple-select-ftl-error-fix fix I extracted template/simple/select.ftl from the struts2-core-2.0.7.jar to WEB-INF/classes/template/simple/select.ftlI thenchanged line 60 from:to:and I inserted the following line before http://www.vogella.com/tutorials/FreeMarker/article.html line 60:<#assign itemKeyStr=itemKey.toString() />I got the idea from another .ftl file that does something similar.The error message this fixed was:Error on error on line 60, column 22 in template/simple/select.ftlExpecting a string, date or number here, Expression itemKey is instead a freemarker.ext.beans.BooleanModelThe problematic instruction:----------==> ${itemKey?html} [on line 60, column 20 in template/simple/select.ftl]in user-directive s.iterator [on line 41, column 1 in template/simple/select.ftl]----------Java backtrace for programmers:----------freemarker.core.NonStringException: Error error on line on line 60, column 22 in template/simple/select.ftlExpecting a string, date or number here, Expression itemKey is instead a freemarker.ext.beans.BooleanModel--This message is automatically generated by JIRA.-You can reply to this email to add a comment to the issue online. reply Tweet Search Discussions Search All Groups issues 5 responses Oldest Nested Don Brown (JIRA) [ https://issues.apache.org/struts/browse/WW-1887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Don Brown updated WW-1887: -------------------------- Fix Version/s: 2.0.9 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. Don Brown (JIRA) at May 22, 2007 at 12:04 pm ⇧ [ https://issues.apache.org/struts/browse/WW-1887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]Don Brown updated WW-1887:--------------------------Fix Version/s: 2.0.9struts 2.0.7 template/simple/select.ftl error/fix-------------------------------------------------Key: WW-1887URL: https://issues.apache.org/struts/browse/WW-1887Project: Struts 2Issue Type: BugReporter: Jason ThurstonFix For: 2.0.9To fix I extracted template/simple/select.ftl
tricks 5.1. Reuse common template fragments 5.2. Variables 5.3. Handling null/undefined values 5.4. Escape 6. About this website 7. Links and Literature 7.1. FreeMarker homepage 7.2. vogella GmbH training and consulting support Appendix A: Copyright and License FreeMarker Tutorial. This tutorial explains how can you define FreeMarker templates and how can you generate output based on these templates. It also demonstrates the usage of macros. 1. Introduction to FreeMarker FreeMarker is a Java-based template engine which can be used in stand-alone or servlet-based Java programs. In FreeMarker you define templates, which are text files that contain the desired output, except that they contain placeholders like ${name}, and even some logic like conditionals, loops, etc. In your Java program you supply the actual values for these placeholders and the final output is generated based on this input. The input of templates is a bunch of named variables that you usually provide as a Map