2018-09-15 12:11

@netwild 是的,对于开放系统就存在很大隐患

2018-09-10 18:32

@JFinal 好像效率是低一些,看了jfinal的render方法
OutputStream os = response.getOutputStream();
engine.getTemplate(view).render(data, os);
我考虑去找一个简易的web包来实现一下试试看,渲染成静态文件(html)的好处是便于理解jar都做了哪些工作

2018-09-10 18:27

@JFinal 哈哈,是哎,因为我没找到好用的可以直接展示页面的方法哎

2018-09-10 18:24

@JFinal 如果为此引入一个jfinal+jetty-server倒也不是不可以,只是偏重了一些

2018-09-10 18:22

@JFinal 不,如果只是devMode那如何获取视图,还是enjoy自带web服务?为了获取最终的html页面,我是调用了下面的代码,渲染成文件,然后自启一个web服务器来进行渲染的
File destFile=Paths.get(".","preview/"+view+".html").toFile();
Config.engine.getTemplate("source/page/"+view+".html").render(null,destFile);

2018-09-06 13:40

恩恩,原来有,没注意到,给力

2018-09-06 11:39

读取的关键就在 this.getClass().getClassLoader().getResourceAsStream(tplPath);

2018-09-06 11:38

这个是其中一个解决办法,但是其实只有layout.html是在jar内,其他模板文件是在jar外,所以希望3.5增加一个JarSource implements ISource来实现jar内文件的读取,读取方法可以参考http://hxraid.iteye.com/blog/483115,我的代码如下
/**
* @author Catch
* @date 2018-09-06 上午10:15
* @description JarSource 用于从jar中加载模板内容
*/
public class JarSource implements ISource {
private static String tplPath;

public JarSource(String templatePath) {
tplPath = templatePath;
}

@Override
public boolean isModified() {
return false;
}

@Override
public String getKey() {
return tplPath;
}

@Override
public StringBuilder getContent() {
InputStream is = this.getClass().getClassLoader().getResourceAsStream(tplPath);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
try {
String temp;
while ((temp=br.readLine() )!= null){
sb.append(temp);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb;
}

@Override
public String getEncoding() {
return EngineConfig.DEFAULT_ENCODING;
}
}

2018-09-06 11:09

目前已通过发现问题,问题出在ret内置的json转换上