[
https://issues.apache.org/jira/browse/FREEMARKER-221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17783577#comment-17783577
]
Benjamin Marwell commented on FREEMARKER-221:
---------------------------------------------
Hi [~startjava]
Can you please add code markup?
Also, I do not see you assigning {{RequestParameters}} to the template model.
> version 2.3.32 RequestParameters has bug?
> -----------------------------------------
>
> Key: FREEMARKER-221
> URL: https://issues.apache.org/jira/browse/FREEMARKER-221
> Project: Apache Freemarker
> Issue Type: Bug
> Reporter: startjava
> Priority: Major
>
> use url:
> [http://localhost:8080/test20?selectedValue=d]
>
> template code:
> <select>
> <#if listString?? && listString?size!=0>
> <#list listString as list>
> <#if RequestParameters['selectedValue']==list>
> <option value="${list}" selected="selected">${list}</option>
> </#if>
> <#if RequestParameters['selectedValue']!=list>
> <option value="${list}">${list}</option>
> </#if>
> </#list>
> </#if>
> <select>
> controller code:
> @RequestMapping("test20")
> public String test20(Model model,HttpServletRequest
> request,HttpServletResponse response){
> List listString=new ArrayList();
> listString.add("a");
> listString.add("b");
> listString.add("c");
> listString.add("d");
> listString.add("e");
> request.setAttribute("listString",listString);
> return "test20";
> }
>
> run result :
> freemarker.core.InvalidReferenceException: The following has evaluated to
> null or missing:
> ==> RequestParameters [in template "test20.ftlh" at line 12, column 12]
> ----
> Tip: If the failing expression is known to legally refer to something that's
> sometimes 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: #if RequestParameters.selectedValue =...
> [in template "test20.ftlh" at line 12, column 7]
>
> but use 2.3.31 no exception !
>
>
>
>
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)