Spring 表单 select 未将值显示为 selected 值

Spring form select not displaying the value as the selected value

我正在使用表单 select,但是下拉列表的值没有显示,因为 selected.I 具有以下模型

 public class Customer{
 public ConditionalBean conditional
}

ConditionalBean如下:

public class ConditionalBean {
 private String conditionalName;
 private String conditionalType;
}

在jsp我有以下

<form:select path=customer.conditional.conditionalName>
  <form:options items="${optionsMap}"/>
 </form:select>

当我显示条件名称时

   <td>${customer.conditional.conditionalName}</td>

显示正确

但是在下拉列表中 select 的值并未显示为 selected。 我已经能够成功地为其他下拉菜单执行此操作,其中路径引用常规字符串。 在这里,它是 ConditionalBean 对象的 conditonalName。

知道如何解决这个问题吗?我研究过使用 PropertyEditorSupport,但不确定如何使用它。

select 的选项创建如下:

   Map<String,String>optionsMap = new HashMap<String,String>
   optionsMap.put(conditionalName,conditionalName);

感谢 kuldeep S Chauhan 的提示。我检查了填充选项的地图中的值,并确定该键具有尾随 space。修剪 space 后,它可以正确显示。 谢谢!