[英]Velocity - dropdown based on hashmap, display values on selection
I have a HashMap< String, List< Integer>>
. 我有一个
HashMap< String, List< Integer>>
。 Is it possible for me to display a dropdown box in velocity based on the String keys in the HashMap
and when the user makes its selection to display the List< Integer>
below the dropdown? 我是否可以基于
HashMap
的String键在速度上显示一个下拉框,并且当用户进行选择以在下拉列表下方显示List< Integer>
?
Velocity is server side, HTML lives in a browser on the client side. Velocity是服务器端,HTML驻留在客户端的浏览器中。 When the user interacts with page, Velocity has long since ceased to be executed.
当用户与页面进行交互时,Velocity早已停止执行。 So no, you can not use values from the live DOM in Velocity.
因此,不能,您不能在Velocity中使用实时DOM中的值。 You can, however, send back the selected value to Velocity:
但是,您可以将所选值发送回Velocity:
<select>
that lists the top level options, in a <form>
<form>
以<form>
呈现初始HTML页面,其中<select>
列出了顶级选项。 <select>
and submits the form <select>
选择某项并提交表单 If you don't want two page loads, you can either use an AJAX request to get just the list of valid values, or you can send the whole map in the first step (hidden in the HTML) and process it clientside with JavaScript. 如果您不希望加载两个页面,则可以使用AJAX请求仅获取有效值列表,也可以在第一步中发送整个地图(隐藏在HTML中)并使用JavaScript在客户端进行处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.