You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "startjava (Jira)" <ji...@apache.org> on 2023/09/08 03:21:00 UTC
[jira] [Created] (FREEMARKER-221) version 2.3.32 RequestParameters has bug?
startjava created FREEMARKER-221:
------------------------------------
Summary: 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
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)