2018-09-14 12:29

以上代码,只执行最后一个renderJson,renderFile是不会执行的

2018-09-13 16:23

renderFile具体下载本地的哪里,服务端是没法决定的.浏览器或是app端设置

2018-09-13 16:21

BaseUploadPath 是用在前端上传是保存到服务端的基路径
BaseDownloadPath 是你renderFile()时,从服务器上下载到本地时,文件在服务器端存放的基路径

2018-09-03 11:34

可以看看这个 http://www.jfinal.com/share/1143

2018-08-27 23:40

@JFinal datePatter这个知道,但是怎样配置才能把date转成时间戳?

2018-08-04 18:12

把拦截器的业务代码写到 inv.invoke() 之前

2018-06-13 13:24

spring源码太多, 不看也情有可原,.jboot以jfinal为基础, 这也不想看就有点说不过去了.小木学堂有视频,是因为它有的视频收费. 开源项目不容易,怎么发展,作者肯定有自己的打算,我们使用者是没资格说三道四的.

2018-05-18 20:23

package cn.flyinke.jke.thymeleaf.common;

import java.io.PrintWriter;

import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.WebContext;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;

import com.jfinal.config.Constants;
import com.jfinal.core.JFinal;
import com.jfinal.render.Render;
import com.jfinal.render.RenderException;


public class ThymeleafRender extends Render {

private static TemplateEngine templateEngine;
private static String encoding = "UTF-8";
private static String contentType = "text/html; charset=" + encoding;
private static String templateMode = "HTML5";
private static String prefix = "/";
private static String suffix = ".html";

public ThymeleafRender(String view) {
this.view = view;
}

public static void setTemplateMode(String templateMode) {
ThymeleafRender.templateMode = templateMode;
}

public static void setPrefix(String prefix) {
ThymeleafRender.prefix = prefix;
}

public void setSuffix(String suffix) {
ThymeleafRender.suffix = suffix;
}

public static void init() {
if (templateEngine != null) {
return;
}

Constants me = JFinal.me().getConstants();
encoding = me.getEncoding();
contentType = "text/html; charset=" + encoding;

ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(JFinal.me().getServletContext());

// XHTML is the default mode, but we will set it anyway for better understanding of code
templateResolver.setTemplateMode(templateMode);
templateResolver.setPrefix(prefix);
templateResolver.setSuffix(suffix);
//templateResolver.setCharacterEncoding("UTF-8");
templateResolver.setCharacterEncoding(encoding);
// Set template cache TTL to 1 hour. If not set, entries would live in cache until expelled by LRU
templateResolver.setCacheTTLMs(Long.valueOf(3600000L));

templateResolver.setCacheable(!me.getDevMode());

templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);

}

@Override
public void render() {
response.setContentType(contentType);
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);

WebContext context = new WebContext(request, response, request.getServletContext(), request.getLocale());
// for (Enumeration attrs=request.getAttributeNames(); attrs.hasMoreElements();) {
// String attrName = attrs.nextElement();
// context.setVariable(attrName, request.getAttribute(attrName));
// }

PrintWriter writer = null;
try {
writer = response.getWriter();
templateEngine.process(view, context, writer);
} catch (Exception e) {
throw new RenderException(e);
}
finally {
if (writer != null)
writer.close();
}
}
}

2018-05-10 00:45

留名

2018-03-08 17:43

@JFinal 学习了,没想到还可以这样玩

2017-10-12 10:43

看来没事要多看看手册