MVC保留回车符-HTML中的换行 [英] MVC Preserve carriage return - line feed in html

查看:58
本文介绍了MVC保留回车符-HTML中的换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的数据库中有一个带有crlf的字段,我该如何保存在HTML中?

If have a field in my database with crlf's how do I preserve that in HTML??

是否有标准的方法?

马尔科姆

如果有帮助,我实际上正在做一个MVC应用.

I am actually doing an MVC app if that hepls.

推荐答案

我认为最好的方法是将 \ r \ n 序列替换为< br/> 标签,使用数据库支持的网站所使用的任何脚本语言.

I think the best way to do that is to replace the \r\n sequence with <br /> tags, using whatever scripting language your database-backed website is in.

其他选项包括将文本放在< textarea> 中.或者,如果适合您的站点,请使用类似于< pre> 标记(或CSS属性 white-space:pre )的标签.

Other options include placing the text within a <textarea>. Or, if it is appropriate for your site, using akin to the <pre> tag (or the CSS attribute white-space: pre).

这篇关于MVC保留回车符-HTML中的换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆