我有一个复选框的HTML列表,它是使用 Freemarker 动态创建的。 Html看起来像这样:
<div data-role="collapsible">
<h4>Software</h4>
<form action="/" method="POST">
<ul data-role="listview" >
<#list softwareoptions as software>
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="${software}" autocomplete="off" >${software}
</#list>
</ul>
</form>
</div>
这是生成的列表:
<div data-role="collapsible">
<h4>Software</h4>
<form action="/" method="POST">
<ul data-role="listview" >
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Adobe Creative Cloud" autocomplete="off" >Adobe Creative Cloud
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Adobe Web Premium" autocomplete="off" >Adobe Web Premium
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="MATLAB" autocomplete="off" >MATLAB
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Quicken" autocomplete="off" >Quicken
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Steam" autocomplete="off" >Steam
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="IBM SPSS Statistics" autocomplete="off" >IBM SPSS Statistics
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft SQL Server 2008" autocomplete="off" >Microsoft SQL Server 2008
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft SQL Server 2012" autocomplete="off" >Microsoft SQL Server 2012
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft Office" autocomplete="off" >Microsoft Office
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Autodesk Infrastructure Design Suite" autocomplete="off" >Autodesk Infrastructure Design Suite
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft Visual Studio 2010" autocomplete="off" >Microsoft Visual Studio 2010
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft Visual Studio 2013" autocomplete="off" >Microsoft Visual Studio 2013
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft Visual Studio 2015" autocomplete="off" >Microsoft Visual Studio 2015
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft Visio" autocomplete="off" >Microsoft Visio
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Unity 3d" autocomplete="off" >Unity 3d
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="GIMP" autocomplete="off" >GIMP
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Maxon CINEMA 4D Broadcast" autocomplete="off" >Maxon CINEMA 4D Broadcast
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="CrazyBump" autocomplete="off" >CrazyBump
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="FRAPS" autocomplete="off" >FRAPS
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="InfraRecorder" autocomplete="off" >InfraRecorder
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Garageband" autocomplete="off" >Garageband
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Microsoft Project" autocomplete="off" >Microsoft Project
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Numbers" autocomplete="off" >Numbers
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Pages" autocomplete="off" >Pages
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Fontographer" autocomplete="off" >Fontographer
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Keynote" autocomplete="off" >Keynote
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Wacom Tablet" autocomplete="off" >Wacom Tablet
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Arduino" autocomplete="off" >Arduino
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="iBooks" autocomplete="off" >iBooks
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="iMovie" autocomplete="off" >iMovie
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="Logic Pro X" autocomplete="off" >Logic Pro X
<input type="checkbox" id="softwarefilter" name="softwarefilter" value="iTunes" autocomplete="off" >iTunes
</ul>
</form>
</div>
要请求复选框的值,我使用Java代码:
Object softstring = request.queryParams("softwarefilter");
但是,这仅返回选中的第一个复选框名称的字符串值。例如,如果选中Adobe Creative Suite和MATLAB,则为softstring =&#34; Adobe Creative Suite&#34;。
当我使用时:
Object softstring = request.queryParamsValues("softwarefilter");
或
QueryParamsMap softmap = request.queryMap("softwarefilter");
我分别获得一个空数组和一个空映射。关于我可能遗失的任何提示?