Skip to content

Commit

Permalink
Jboot v1.2.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfuhai committed Dec 25, 2017
1 parent dc0a9a5 commit 9e1f796
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 49 deletions.
5 changes: 5 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
jboot-1.2.1:
修复:JbootModel 的 NullPointerException 异常问题
修复:Controller rendderXml 和 renderTemplate 的时候,无法使用 ActionCache 的问题


jboot-1.2.0:
新增:新增 JbootShiroCacheManager ,用于 给shiro.ini 进行配置使用 Jboot 默认缓存
新增:EnableActionCache 和 ActionCacheClear 注解,用于对action进行配置高速页面缓存
Expand Down
49 changes: 1 addition & 48 deletions src/main/java/io/jboot/web/render/JbootTemplateRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,15 @@
*/
package io.jboot.web.render;

import com.jfinal.render.TemplateRender;
import com.jfinal.template.Engine;
import io.jboot.Jboot;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
* @author Michael Yang 杨福海 ([email protected]
* @version V1.0
* @Package io.jboot.web.render
*/
public class JbootTemplateRender extends TemplateRender {

private JbootRenderConfig config;
public class JbootTemplateRender extends JbootRender {


public JbootTemplateRender(String view) {
super(view);
this.config = Jboot.config(JbootRenderConfig.class);
}

private static Engine engine;

private static final String contentType = "text/html; charset=" + getEncoding();

static void init(Engine engine) {
if (engine == null) {
throw new IllegalArgumentException("engine can not be null");
}
JbootTemplateRender.engine = engine;
}

public String getContentType() {
return contentType;
}

@Override
public void render() {
response.setContentType(getContentType());

Map<Object, Object> data = new HashMap<Object, Object>();
for (Enumeration<String> attrs = request.getAttributeNames(); attrs.hasMoreElements(); ) {
String attrName = attrs.nextElement();
data.put(attrName, request.getAttribute(attrName));
}

String html = engine.getTemplate(view).renderToString(data);
html = config.isEnableCdn() ? RenderHelpler.processCDN(html) : html;
RenderHelpler.actionCacheExec(html, contentType);
RenderHelpler.renderHtml(response, html, contentType);
}


public String toString() {
return view;
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/jboot/web/render/JbootXmlRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @version V1.0
* @Package io.jboot.web.render
*/
public class JbootXmlRender extends JbootTemplateRender {
public class JbootXmlRender extends JbootRender {

private static final String contentType = "text/xml; charset=" + getEncoding();

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/actioncache/ActionCacheDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package actioncache;

import io.jboot.Jboot;
import io.jboot.web.cache.ActionCacheClear;
import io.jboot.web.cache.EnableActionCache;
import io.jboot.web.controller.JbootController;
import io.jboot.web.controller.annotation.RequestMapping;
Expand All @@ -35,6 +36,7 @@ public void index() {
renderHtml("index");
}

@ActionCacheClear("test")
public void clear() {
System.out.println("clear() invoke!!!!");
renderHtml("clear ok!!!");
Expand All @@ -47,6 +49,13 @@ public void cache() {
renderHtml("render ok");
}


@EnableActionCache(group = "test#(id)")
public void template() {
System.out.println("template() invoke!!!!");
renderTemplate("/test.html");
}

@EnableActionCache(group = "test")
public void json() {
System.out.println("json() invoke!!!!");
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<body>


test....

#testDirective(name="michael")
#(user.name ??) <br />
#end
Expand Down

0 comments on commit 9e1f796

Please sign in to comment.