开发者

Struts <bean:write> tags

How do I escape character like '&' in struts tags. For example we can mention.

&开发者_C百科lt;a href="./testaction.do?testmethod=bookResult&bookTitle=<bean:write name="booklist" property="title"/>" class="nLink"><bean:write name="booklist" property="title"/></a></small>

I'm iteration over a book list array (booklist) and setting book titles one by one.In this scenario I need to escape characters like '&' within the 'title' property in order execute the respective logic for that particular action.

Thanks.


Maybe use the filter attribute?

<bean:write name="booklist" property="title" filter="true" />

More on <bean:write>. The documentation states:

If this attribute is set to true, the rendered property value will be filtered for characters that are sensitive in HTML, and any such characters will be replaced by their entity equivalents.


I suppose that you want to show the book title on URL bar (or use it in the URL).
And some of the book title is having '&' in their title.
If so? you have to replace it with '%26'.
Replace this in the action where you are setting the collection.
If you are fetching it from DB, then replace it in sql query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜