|
@@ -1,9 +1,12 @@
|
|
|
package com.ruoyi.web.controller.common;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.ruoyi.web.controller.utils.HtmlGenerator;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -160,4 +163,34 @@ public class CommonController
|
|
|
log.error("下载文件失败", e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件生成测试(单个)
|
|
|
+ */
|
|
|
+ @GetMapping("/filetext")
|
|
|
+ public AjaxResult filetext() throws Exception
|
|
|
+ {
|
|
|
+ String html = "<html>\n" +
|
|
|
+ "<head>\n" +
|
|
|
+ "<title>Java生成HTML示例</title>\n" +
|
|
|
+ "</head>\n" +
|
|
|
+ "<body>\n" +
|
|
|
+ "Hello, World!\n" +
|
|
|
+ "</body>\n" +
|
|
|
+ "</html>";
|
|
|
+
|
|
|
+ // 将HTML内容写入文件
|
|
|
+ String folderPath = RuoYiConfig.getImportPath();
|
|
|
+ // 创建File对象
|
|
|
+ File folder = new File(folderPath);
|
|
|
+ // 检查文件夹是否存在
|
|
|
+ if (!folder.exists()) {
|
|
|
+ // 不存在则创建文件夹
|
|
|
+ folder.mkdirs();
|
|
|
+ }
|
|
|
+ String path = RuoYiConfig.getImportPath()+"/output.html";
|
|
|
+ HtmlGenerator.writeHtmlToFile(html, path);
|
|
|
+ return AjaxResult.success(path);
|
|
|
+ }
|
|
|
+
|
|
|
}
|