作者:嘿嘿可爱无罪 | 来源:互联网 | 2023-10-13 13:47
通过JSP将回车符转化成HTML标签
方法一:
public String replace(String parentStr,String ch,String rep) {
int i = parentStr.indexOf(ch);
StringBuffer sb = new StringBuffer();
if (i == -1)
return parentStr;
sb.append(parentStr.substring(0,i) + rep);
if (i+ch.length() < parentStr.length())
sb.append(replace(parentStr.substring(i+ch.length(),parentStr.length()),ch,rep));
return sb.toString();
}
%>
<%//调用
str=replace(str," "," ");
str=replace(str,"/n","
");
%>
方法二:
replace("/r/n" ,"
");