如何过滤字段中html代码只显示里面的文字? ???你的前台是什么?如果你的前台是浏览器之类,HTML代码是不会显示在浏览器上的,这个你不会不知道吧? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 做一个过滤类,用来处理内容,把内容的Html代码全部替换掉。 不会写这个类,有例子吗简单的想是不是将<>符号里边字符过滤掉? 用Allreplace这个函数来替换就行了.. ===========================================================================截取内容中部分字符,同时它也会连同html代码一并输出我只要内容中文字(例如汉字或英文字母)=========================================================================== public static String stringLength(String str ,int length) { int lengthCount = str.length(); int strLength = str.length(); int m_length = length; try { for (int i = 0; i < lengthCount; i++) { char c = str.charAt(i); if (c >= 256) { length++; strLength++; } } if (strLength > length) { str = str.substring(0, m_length) + "..."; } } catch(Exception e) { } return str; }} 写的第一个jsp程序就运行不了 新手问题 100分请教深度问题 sun.net.ftp如何设置默认链接超时时间 请问什么是CVS 高分求java blend的资料 JSP显示数据库图片数据问题,急啊!! 只用dreamweaver能不能直接调试jsp???? 请教高人:tomcat服务器怎样在客户session超时后,向客户端发送信息? [ 急 ] 有关Apache Lucene的中文问题 有关记事本的源代码问题 到哪里下载isapi_redirector.dll?在http://jakarta.apache.org站点找不到
简单的想是不是将<>符号里边字符过滤掉?
截取内容中部分字符,同时它也会连同html代码一并输出
我只要内容中文字(例如汉字或英文字母)===========================================================================
public static String stringLength(String str ,int length) {
int lengthCount = str.length();
int strLength = str.length();
int m_length = length;
try {
for (int i = 0; i < lengthCount; i++) {
char c = str.charAt(i);
if (c >= 256) {
length++;
strLength++;
}
}
if (strLength > length) {
str = str.substring(0, m_length) + "...";
}
} catch(Exception e) {
}
return str;
}}