MoienGK
MoienGK

Reputation: 4654

printing string as html components in struts

i am putting <input type="text" name="Job Name" value=""/> inside private List<String> dataFields; and iterate it in my jsp page with struts like :

<logic:iterate name="dataFields" id="dataFieldsId">
<p>
  List Messages <bean:write name="dataFieldsId"/>
</p>
</logic:iterate>

but my browser instead of showing me a input box, it prints me the exact String that i have put in my action class, i mean this : <input type="text" name="Job Name" value=""/> what can i do to solve this?

edit --------- actually the above syntax is for struts 1, i changed my iterator to struts 2 and the code now is :

<s:iterator  value="dataFields"  var="dataFieldsId">
<p>
  <s:property escapeHtml="false" value="dataFieldsId" />
</p>
</s:iterator>

and it is working like a charm

Upvotes: 2

Views: 3114

Answers (2)

SilverMoon
SilverMoon

Reputation: 56

I found this problem in my past project. Please, try this like the following :

<logic:iterate name="dataFields" id="dataFieldsId">
<p>
List Messages <input type="text" name="Job Name" value="<bean:write name="dataFieldsId""/>
</p>
</logic:iterate>

Upvotes: -1

Bogdan
Bogdan

Reputation: 24590

It's because the value is filtered for HTML characters and they are replaced by their entity equivalents. Try the filter attribute like so:

<bean:write name="dataFieldsId" filter="false" />

Upvotes: 3

Related Questions