简体   繁体   English

如何在 JSP 中默认选择选项

[英]How to make option selected by default in JSP

I am trying to create a drop down with some value selected by default using the following approach, but this does not works我正在尝试使用以下方法创建一个带有默认选择的值的下拉列表,但这不起作用

<a:dropdownOption value="group_${dropdownItem.groupId}" selected="${ ('${dropdownItem.groupName}' == 'All groups')? 'selected': ''}"> ${dropdownItem.groupName} </a:dropdownOption> <a:dropdownOption value="group_${dropdownItem.groupId}" selected="${ ('${dropdownItem.groupName}' == 'All groups')? 'selected': ''}"> ${dropdownItem.组名} </a:dropdownOption>

Any suggestions on what should be modified in it?关于应该修改什么的任何建议?

Used the following approach to get this done使用以下方法完成此操作

<a:dropdownOption value="group_${dropdownItem.groupId}" selected="${dropdownItem.groupName eq 'All groups'? 'true': ''}"> <a:dropdownOption value="group_${dropdownItem.groupId}" selected="${dropdownItem.groupName eq '所有组'?'true': ''}">

Here, i compared the groupName of drop down item with the desired group name and then assigned true to selected based on if it has the desired group name.在这里,我将下拉项目的 groupName 与所需的组名进行了比较,然后根据它是否具有所需的组名将其分配给 selected 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM