我做了一个新闻发布系统,所有文本均存到数据库中,但是不能保存格式,如空格,回车等均不能显示,所有内容均连在一起,请问怎么解决呀!!在线等……
解决方案 »
- 《CXF》怎么样好么?它比Axis2优秀么?
- jsp页面怎么判断输入的文本符合数据库中datetime类型的显示格式
- 关于BeanUtils.copyProperties()的问题,急!
- tomcat 连接池配置
- 跪求问题解决办法!谢谢大侠们!急!
- 请问这个servlet该怎么写,servlet mapping如何配置????
- 关于页面刷新,A页面填写数据项,在B页面需要调用A页面的数据项,如何实现同步刷新?我现在必须关闭IE从新登陆才可以看到新数据
- 求救: Date转成Timestamp的问题???
- listbox如何添加数据??? --高分求救!!!
- 关于WEB接口开发-传出参数数量的变化需要单独再另外新建对象作为载体吗
- JNI使用的问题?
- csdn的同志们有劳了,帮一下小忙
replaceAll("\r","<br>")
replaceAll("\n","<br>"),
if request("html")="1" then
htmlencode=replace(replace(str,chr(13),"<br>"),"'","’")
else
htmlencode=server.htmlencode(str)
htmlencode=replace(replace(replace(replace(str,"<","<"),">",">"),chr(13),"<br>")," "," ")
htmlencode=replace(replace(replace(replace(replace(replace(htmlencode,"","></img>"),"","</b>"),"[/red]","</font>"),"[/big]","</font>"),"[/blue]","</font>"),"[/lime]","</font>")
end if
end function你可以参照一下这个,我用asp做的
免费招聘、求职。IT人工作的天堂。希望能够为大家所用。
String Replace(String str_source, String str_original, String str_new){
if(str_source == null)
return null;
StringBuffer output = new StringBuffer();
int lengOfsource = str_source.length();
int lengOfold = str_original.length();
int posStart = 0;
int pos;
while((pos = str_source.indexOf(str_original, posStart)) >= 0){
output.append(str_source.substring(posStart, pos));
output.append(str_new);
posStart = pos + lengOfold;
}
if(posStart < lengOfsource){
output.append(str_source.substring(posStart));
}
return output.toString();
}
String toHtml(String s){
s = Replace(s, "<", "<");
s = Replace(s, ">", ">");
s = Replace(s, "&", "&");
s = Replace(s, "\t", " ");
s = Replace(s, "\r\n", "\n");
s = Replace(s, "\n", "<br>");
s = Replace(s, " ", " ");
s = Replace(s, "'", "'");
s = Replace(s, "\\", "\");
return s;
}
String unHtml(String s){
s = Replace(s, " "," ");
s = Replace(s, "<br>", "\n");
return s;
}
%>
replaceAll("\r","<br>")
replaceAll("\n","<br>"),
如:
String content = newsinfo.getContent;//取出数据库中的值
String content1 = "";
if(content!=null){
content1 = content.replaceAll("\n","<br>");//得到回车
}然后就可以将content1写在你的表单中,这样就可以得到你所要的了