2017-07-27 11:38
@JFinal
String strSql = " select * from _tree";
List ls = Db.find(strSql);
List mls = new ArrayList();
for (int i = 0; i < ls.size(); i++) {
TreeNode m = new TreeNode();
mls.add(m.put(ls.get(i)));
}
TreeBuilder tree = new TreeBuilder();
renderJson(tree.buildListToTree(mls));
2017-07-05 09:24
@JFinal 并且这么写的话
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
request.setAttribute("title", "环境监管网络平台");
next.handle(target, request, response, isHandled);
}
这个不起作用了
2017-07-05 09:23
@JFinal Engine.use().getTemplate(target).render(map, response.getWriter());
BaseTemplatePath是null。
me.setBaseTemplatePath(PathKit.getWebRootPath());也不管用。
我是看网上这么写的
public class HtmlHandler extends Handler {
Engine engine = Engine.use();
{
engine.setBaseTemplatePath(PathKit.getWebRootPath());
engine.setEncoding("UTF-8");
}
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
//必须先设置,但无效 me.setBaseTemplatePath(PathKit.getWebRootPath());
response.setCharacterEncoding("UTF-8");
if (target.endsWith(".html")) {
try {
Map map = new HashMap();
map.put("jia", "1");
Engine.use().getTemplate(target).render(map, response.getWriter());
} catch (IOException e) {
e.printStackTrace();
}
isHandled[0] = true;
} else {
next.handle(target, request, response, isHandled);
}
map是不增加了 不增加 null 不行。