处理完HTML里面回车符 的问题

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

目的:按用户的“本来面目”显示录入的数据 --有回车的话显示处理就得换行。。。。

操作数据库代码里:

String text = text1.replaceAll("\n","<br>").trim();

boardItem.setText(text);

在detail页面上:<bean:write name = "BoardItemForm" property="text" filter="flase"/>

~~~~~关键

但是在edit页面遇到了问题:

这样行不通:(回车的地方都显示成了<br>)

<html:textarea property="text" cols="50" rows="10" value="<bean:write name = "BoardItemForm" property="text" filter="flase"/>">

</html:textarea>

找了不少资料,其中有一个人提到:

In Ted's answer above, it is given: value="<bean:write name="employeeBean" property="name"/>" value should be enclosed in single quotes and not double quotes. value='<bean:write name="employeeBean" property="name"/>' It will work. Courtesy: Ted's own Struts book.

http://www.jguru.com/faq/view.jsp?EID=1023589

Failed too!

So i chose define tag,but it doesn't have filter value

For about half of hour's thinking,at last I chose:

<!--replace <br> with \n-->

<bean:define id="text" name="BoardItemForm" property="text" type="String"/>

<%

String realText = text.replaceAll("<br>","\n");

%>

<bean:message key="common.text"/>:

<html:textarea property="text" cols="50" rows="10" value="<%=realText%>">

</html:textarea>

ok,done although not so perfect!

It's time to go to bed!

Good night!

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航