ソースを参照

!67 update src/main/java/com/jfinal/template/source/StringSource.java.
Merge pull request !67 from hzh740053757/N/A

JFinal 4 年 前
コミット
680cc72ca8
1 ファイル変更17 行追加1 行削除
  1. 17 1
      src/main/java/com/jfinal/template/source/StringSource.java

+ 17 - 1
src/main/java/com/jfinal/template/source/StringSource.java

@@ -40,7 +40,15 @@ public class StringSource implements ISource {
 		this.content = new StringBuilder(content);
 		this.content = new StringBuilder(content);
 		this.cacheKey = cache ? HashKit.md5(content) : null;	// 不缓存只要将 cacheKey 值赋为 null 即可
 		this.cacheKey = cache ? HashKit.md5(content) : null;	// 不缓存只要将 cacheKey 值赋为 null 即可
 	}
 	}
-	
+
+	public StringSource(String content, String cacheKey) {
+		if (StrKit.isBlank(content)) {
+			throw new IllegalArgumentException("content can not be blank");
+		}
+		this.content = new StringBuilder(content);
+		this.cacheKey = cacheKey;	// 不缓存只要将 cacheKey 值赋为 null 即可
+	}
+
 	public StringSource(StringBuilder content, boolean cache) {
 	public StringSource(StringBuilder content, boolean cache) {
 		if (content == null || content.length() == 0) {
 		if (content == null || content.length() == 0) {
 			throw new IllegalArgumentException("content can not be blank");
 			throw new IllegalArgumentException("content can not be blank");
@@ -48,6 +56,14 @@ public class StringSource implements ISource {
 		this.content = content;
 		this.content = content;
 		this.cacheKey = cache ? HashKit.md5(content.toString()) : null;	// 不缓存只要将 cacheKey 值赋为 null 即可
 		this.cacheKey = cache ? HashKit.md5(content.toString()) : null;	// 不缓存只要将 cacheKey 值赋为 null 即可
 	}
 	}
+
+    public StringSource(StringBuilder content, String cacheKey) {
+		if (content == null || content.length() == 0) {
+			throw new IllegalArgumentException("content can not be blank");
+		}
+		this.content = content;
+		this.cacheKey = cacheKey;	// 不缓存只要将 cacheKey 值赋为 null 即可
+	}
 	
 	
 	public boolean isModified() {
 	public boolean isModified() {
 		return false;
 		return false;