textarea JSP JAVA 急急急

pitouone 2007-12-26 09:09:24
我在textarea中输入内容后。
然后,存在数据中
在表格中。从数据库中取出来。为什么,格式和输入格式不一样。

怎么调试成,和输入时格式一样。
请尽快回复。
...全文
123 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
linpyi 2007-12-28
  • 打赏
  • 举报
回复
我想楼主是想写个编辑器吧,就象CSDN这样发表的编辑器,做BLOG的时候可能会用,网上有免费的编辑器源码,楼主可以尝试下,至于TEXTAREA输入问题,上次写BLOG也碰到了,别人给我的建议是换个编辑器,所以具体没多大研究
免费编辑器可以看看FCKeditor,(会自动加BR这些换行符)还行功能齐全,可能就是资源可能比较耗
pitouone 2007-12-28
  • 打赏
  • 举报
回复
你说的那个是PHP的哟。不支持JSP哟。呵呵。。。。。。其实,用不用。这个文本编辑器都是一样的个。
主要是。。。能用就行。不报错误就行。
YOYOOOP 2007-12-27
  • 打赏
  • 举报
回复
pitouone 2007-12-27
  • 打赏
  • 举报
回复
谢谢。这个问题好像是解决拉。但是好像。。。每次都要自己输入
<br>
<\n>这些才可以换呀。有没有撒子办法。在输入的时候。让他自己把
换行呀。这些自动解析出来呢?
pitouone 2007-12-27
  • 打赏
  • 举报
回复
问题是现在要显示在。表格里面呀。
pitouone 2007-12-27
  • 打赏
  • 举报
回复
<pre style="word-wrap:break-word;table-layout:fixed;width:580;">
<c:out value="${listVo.contents}" />
</pre>
怎么调试输出的行间距
老紫竹 2007-12-27
  • 打赏
  • 举报
回复
1 对数据进行格式输出
2 数据继续显示在<textarea> 里面

我提供一个格式化输出的方法,调用<%=MyObject.htmlshow(str)%> 就可以了!

public class MyObject {
private static final String _BR = "<br/>";

/**
* 在页面上直接显示文本内容,替换小于号,空格,回车,TAB
*
* @param str String 原始字符串
* @return String 替换后的字符串
*/
public static String htmlshow(String str) {
if (str == null) {
return null;
}

str = replace("<", "<", str);
str = replace(" ", " ", str);
str = replace("\r\n", _BR, str);
str = replace("\n", _BR, str);
str = replace("\t", "    ", str);
return str;
}


/**
* 替换字符串
*
* @param from String 原始字符串
* @param to String 目标字符串
* @param source String 母字符串
* @return String 替换后的字符串
*/
public static String replace(String from, String to, String source) {
if (source == null || from == null || to == null)
return null;
StringBuffer bf = new StringBuffer("");
int index = -1;
while ((index = source.indexOf(from)) != -1) {
bf.append(source.substring(0, index) + to);
source = source.substring(index + from.length());
index = source.indexOf(from);
}
bf.append(source);
return bf.toString();
}
}
pitouone 2007-12-27
  • 打赏
  • 举报
回复
<pre style="word-wrap:break-word;table-layout:fixed;width:580;">
<c:out value="${listVo.contents}" />
</pre>
楼上的谢谢你。但是。这个怎么才能控制它显示在我的表格里面显示不变型呢?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧