Java tutorial
//package com.java2s; import java.util.List; public class Main { private final static String SEARCHKEY_TAG = "${searchkey}"; public static String createSearachkeyHtml(String template, List<String> list) { StringBuffer bf = new StringBuffer(); for (String searchkey : list) { bf.append("<a onclick=\"searchkey('" + searchkey + "')\" href=\"#\">").append(searchkey) .append("</a>\n"); } return template.replace(SEARCHKEY_TAG, bf.toString()); } }