数据库中读出数据换行问题 http://www.csdn.net/expert/topic/783/783200.xml?temp=.5592768 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.csdn.net/expert/topic/759/759652.xml?temp=.7651483 http://www.csdn.net/expert/topic/759/759652.xml?temp=.7651483 //禁用HTML代码编码public String html(String s){ String re; re=replace(s,"<","<"); re=replace(re,">",">"); re=replace(re,"\n","<br>"); re=replace(re," "," "); re=replace(re,"'","'"); return re;}把用户提交的东西,写数据库的时候先禁用html //用指定的字符替换字符串中某个字符public String replace(String con,String tag,String rep){ int j=0; int i=0; int k=0; String RETU=""; String temp=con; int tagc=tag.length(); while(i<con.length()){ if(con.substring(i).startsWith(tag)){ temp=con.substring(j,i)+rep; RETU+=temp; i+=tagc; j=i; } else{i+=1; } } RETU+=con.substring(j); return RETU;}//禁用HTML代码编码public String html(String s){ String re; re=replace(s,"<","<"); re=replace(re,">",">"); re=replace(re,"\n","<br>"); re=replace(re," "," "); re=replace(re,"'","'"); return re;}刚才少给了你一个函数 用这个试试public static String returnToBr(String sStr) { if (sStr == null || sStr.equals("")) { return sStr; } StringBuffer sTmp = new StringBuffer(); int i = 0; while (i <= sStr.length()-1) { if (sStr.charAt(i) == '\n'||sStr.charAt(i)=='\r') { sTmp = sTmp.append("<br>"); } else if (sStr.charAt(i)==' ') { sTmp = sTmp.append(" "); }else { sTmp = sTmp.append(sStr.substring(i,i+1)); } i++; } String S1; S1=sTmp.toString(); return S1; } jsp+access 查询不出结果 oracle表空间管理 struts,jsp,当用户进入系统后,长时间不操作,系统自动退出到登陆界面如何实现?急,等!! 能否判断某条url所链接的资源是什么? 把server.xml文件中的xmlValidation设置成true时Tomcat启动就出错? 了解网页加密进来聊聊! 用update,insert更新Access数据库没有效果? 一个JSP里遇到的问题 在线等怎么配置resin-2.1.6中的srun JSP 调用 JAVA BEAN 不行啊,急....分数全给拉:) 哪里有关于servlet的电子书籍下载 关于重定向
public String html(String s){
String re;
re=replace(s,"<","<");
re=replace(re,">",">");
re=replace(re,"\n","<br>");
re=replace(re," "," ");
re=replace(re,"'","'");
return re;
}把用户提交的东西,写数据库的时候先禁用html
public String replace(String con,String tag,String rep){
int j=0;
int i=0;
int k=0;
String RETU="";
String temp=con;
int tagc=tag.length();
while(i<con.length()){
if(con.substring(i).startsWith(tag)){
temp=con.substring(j,i)+rep;
RETU+=temp;
i+=tagc;
j=i;
}
else{i+=1;
}
}
RETU+=con.substring(j);
return RETU;
}//禁用HTML代码编码
public String html(String s){
String re;
re=replace(s,"<","<");
re=replace(re,">",">");
re=replace(re,"\n","<br>");
re=replace(re," "," ");
re=replace(re,"'","'");
return re;
}刚才少给了你一个函数
public static String returnToBr(String sStr)
{
if (sStr == null || sStr.equals(""))
{
return sStr;
} StringBuffer sTmp = new StringBuffer();
int i = 0;
while (i <= sStr.length()-1)
{
if (sStr.charAt(i) == '\n'||sStr.charAt(i)=='\r')
{
sTmp = sTmp.append("<br>");
} else if (sStr.charAt(i)==' ')
{
sTmp = sTmp.append(" ");
}else
{
sTmp = sTmp.append(sStr.substring(i,i+1));
}
i++;
}
String S1;
S1=sTmp.toString();
return S1;
}