在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
// // StrReplace.java // package forum; import java.util.*; /** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */ public class StrReplace { public StrReplace() { } public String str_replace(String from,String to,String source) { StringBuffer bf= new StringBuffer(""); StringTokenizer st = new StringTokenizer(source,from,true); while (st.hasMoreTokens()) { String tmp = st.nextToken(); System.out.println("*"+tmp); if(tmp.equals(from)) { bf.append(to); } else { bf.append(tmp); } } return bf.toString(); } } // 使用方法 <jsp:useBean id="replace" scope="page" class="forum.StrReplace" /> <%= replace.str_replace("<","^","<h1>123456</h1>") %> |
请发表评论