Saturday, 15 January 2011

java - Replace html content with another html content -



java - Replace html content with another html content -

i have jsp page new.jsp has next content

<div class="parentclass"> <ul>#mylinks</ul> </div> <a href="javascript:void(0)" class="seeall">more</a>

i have replace #mylinks html generate in action class.i read content of jsp page using htmlreader working correctly.but tried using replaceall function replace unwanted content.mypage contains content of jsp page. sublinks content follows

<li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li>

but after using this, output of replacedcontent same.

replacedcontent = mypage.replaceall("#mylinks", sublinks);

i need final output as

<div class="parentclass"> <ul> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> </ul> </div> <a href="javascript:void(0)" class="seeall">more</a>

could help me on this.thanks in advance.. :)

you can utilize different ways it, simple way utilize property or method in action class returns string contains generated html. you can write html straight out.

<ul><s:property value="%{sublinks}" escapehtml="false" /></ul>

of course of study should provide getter sublinks property.

java regex struts2

No comments:

Post a Comment