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

类别:Java 点击:0 评论:0 推荐:
目的:按用户的“本来面目”显示录入的数据 --有回车的话显示处理就得换行。。。。

操作数据库代码里:
  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!

本文地址:http://com.8s8s.com/it/it14604.htm