简体   繁体   English

如何使用列表在文本框中设置标题 <String> 在struts1.x中?

[英]How to set the title on text box using List<String> in struts1.x?

I need to set the tooltip(title) on the html components. 我需要在html组件上设置tooltip(title)。

Here is my code: 这是我的代码:

In Action class: 在动作课中:

  MyForm myForm = (MyForm) form;
  List<String> listOfTitle = new ArrayList<String>();
  listOfTitle.add("AAA");
  listOfTitle.add("BBB");
  listOfTitle.add("CCC");
  listOfTitle.add("DDD");
  myForm.setListOfTitle(listOfTitle);   
  return mapping.findForward("myJsp");

Here the jsp code: 这里的jsp代码:

<td>
 <html:text name="myForm" errorStyleClass="validError" property="name"
 size="20" title="${listOfTitle[0]}"/>
</td>
<td>
 <html:text name="myForm" errorStyleClass="validError" property="address"
 size="20" title="${listOfTitle[1]}" /> 
</td>

but listOfTitle[0],listOfTitle[1] gets empty string (""). 但是listOfTitle[0],listOfTitle[1]获取空字符串(“”)。

please suggest me how i can use the List value using index to display the title on each html components in struts1.x? 请建议我如何使用使用索引的List值在struts1.x中的每个html组件上显示标题?

Thanks in Advance, 提前致谢,

Anand 阿南德

You can access the elements of the list that you have set in the form bean in the title attribute like below. 您可以像下面这样在title属性中访问在form bean中设置的列表元素。

 <html:text name="myForm" errorStyleClass="validError" property="name"size="20" title='${myForm.listOfTitle[0]}'/>

I hope this answers your question. 我希望这回答了你的问题。

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

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