惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
量子位
aimingoo的专栏
aimingoo的专栏
V
V2EX
Vercel News
Vercel News
B
Blog
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
N
News and Events Feed by Topic
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
S
Secure Thoughts
U
Unit 42
博客园 - 叶小钗
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
News | PayPal Newsroom
Help Net Security
Help Net Security
S
Security Affairs
Microsoft Security Blog
Microsoft Security Blog
W
WeLiveSecurity
博客园 - Franky
Forbes - Security
Forbes - Security
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Schneier on Security
Schneier on Security
I
InfoQ
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Webroot Blog
Webroot Blog
AWS News Blog
AWS News Blog
Last Week in AI
Last Week in AI
Security Archives - TechRepublic
Security Archives - TechRepublic
C
CERT Recently Published Vulnerability Notes
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
Lohrmann on Cybersecurity
SecWiki News
SecWiki News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
J
Java Code Geeks

博客园 - 大口仔

网上邻居访问提示"未授予用户在此计算机上的请求登录类型"的解决 获取保存在路由器中的ADSL账号和密码 GX DM800遥控TV设置 硅钢片铁芯、坡莫合金、非晶及纳米晶软磁合金 n!和 Fibnoacci函数的递归与非递归 SQL Server和Oracle的常用函数对比 自动配置IE代理脚本 - 大口仔 - 博客园 DD-WRT 上 VPN 的设置 - 大口仔 数据绑定以及Container.DataItem - 大口仔 - 博客园 css文本 jQuery插件 用户控件路径的解决方案 - 大口仔 - 博客园 CSS属性大全 关闭excel进程 c# 枚举基础 与 枚举属性的访问 首字母大写 SQL Server 2005之PIVOT/UNPIVOT行列转换 Excel导出方法总结
在HTML中显示回车和空格 - 大口仔 - 博客园
大口仔 · 2009-08-04 · via 博客园 - 大口仔

最近正忙着把一个C/S的系统换成B/S的。其中文本编辑换成了FCK编辑器,这样就导致了数据库中的老数据显示的格式不正确了。
解决方案是:首先取出数据str,然后用str.replaceAll(" ","&nbsp;").replaceAll("\r\n", "<br/>");
注意:取出的空格是空白" ",html中空格是&nbsp;同时这种方法也可替换Tab等。

网上有一种解决方案就是使用<pre>标签,w3c对pre元素是这样定义的:pre 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。更详细的内容请参考 http://www.w3school.com.cn/tags/tag_pre.asp也就是说包含在pre标签中的回车和空格会正常的显示出来。包括你在页面代码中输入的。所以如果使用pre元素你需要这样写:<pre>要输出的文本</pre>,而不是这样:
<pre>
      要输出的文本
</pre>后一种写法 文本前的空白也会被显示的。除非你真的希望这样
但我试了一下不行,它将数据转换成了很长的一行.