|
|
@@ -10,13 +10,19 @@ public class TextTempletUtil {
|
|
|
* @param map
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String replaceContent(String context, Map<String,String> map){
|
|
|
+ public static String replaceContent(String context, Map<String, String> map) {
|
|
|
String resultContent;
|
|
|
Iterator keyList = map.keySet().iterator();
|
|
|
- while(keyList.hasNext()){
|
|
|
- String key = (String)keyList.next();
|
|
|
- resultContent = context.replace(key,map.get(key));
|
|
|
- context = resultContent;
|
|
|
+ while (keyList.hasNext()) {
|
|
|
+ String key = (String) keyList.next();
|
|
|
+ try {
|
|
|
+ String value = map.get(key) == null ? "" : map.get(key);
|
|
|
+ resultContent = context.replace(key, value);
|
|
|
+ context = resultContent;
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("key is null vale: " + key);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
return context;
|
|
|
}
|