没有及时发布新闻,真是不好意思。今天打个新闻批发,把 Act 1.7.0 到 1.8.1 中值得注意的更新给大家汇报一下。 Act-1.8.1 - 2018-03-11 支持 Request Forward @GetAction("shortcut/{shortUrl}") public void shortUrlHandler(String shortUrl, UrlMapper urlMapper) { String longUrl = urlMapper.get(shortUrl); Controller.Util.forward(longUrl); } forward 和 redirect 的区别:forward 不会发回 303 给浏览器,而是在应用内部直接分派到相关请求响应器。注意:forward 只支持 HTTP GET 请求 更多 act-1.8.1 的内容 Act-1.8.0 - 2018-03-04 实现了新的响应输出模型,大大优化响应输出的内存,对大字节内容输出性能上有少量提升 项目布局支持 gradle-groovy CacheService 注入支持 @Named // Before private CacheService fooCache = Act.app().cache("foo"); // After @Named("bar") @Inject private barCache; timestamp auditing 支持在 base class 上定义的 timestamp 字段 @MappedSuperClass public class BaseModel { @CreatedAt public Date created; @LastModifiedAt public Date lastModified; } @Configuration 支持 static 字段 @Configuration("foo.bar") public static String fooBar; 更多 act-1.8.0 的内容 Act-1.7.2 - 2018-02-25 支持 Timestamp Audting public class User { public String username; ... @CreatedAt public Date created; @LastModified public Date lastModified; } 更多 act-1.7.2 的内容 Act-1.7.1 - 2018-02-21 允许用户定义 action handler 支持 Partial Path @GetAction("/file/...") public File handleFileRequest(@PartialPath String filePath) { // filePath should be anything in the URL path that after `/file/` } 更多 act-1.7.1 的内容 Act-1.7.0 - 2018-02-19 静态资源支持 DirectoryIndex - 自动查找目录下的 index.html 文件 API Doc TOC 以 HTTP Method 和 URL 组织 @Sensitive 数据字段支持 // creditCardNo 字段内容会被框架加密处理后存入数据库 // 从数据库取出数据时会自动解密 public class User { public String firstName; public String lastName; public String email; public String mobile; @Sensitive public String creditCardNo; } 简化密码字段处理 // 老办法 public class User { public String username; private String passhash; public void setPassword(String password) { passhash = Act.crypto().passwordHash(password); } } // 新办法 public class User { public String username; @Password public String password; } 简化方法执行的测量 // 老方式 public class Foo { private Metric metric = Act.metricPlugin().metric("app"); // measure bar1 execution time public void bar1() { Timer timer = metric.startTimer("bar1"); try { ... } finally { timer.stop(); } } // measure bar2 execution count public void bar2() { metric.countOnce("bar2"); ... } } // 新方式 // define measure namespace. // `("foo")` is optional and can be inferred from class name @MetricLabel("foo") public class Foo { @MeasureTime("bar1") // ("bar1") is optional and can be inferred from method name public void bar1() { ... } @MeasureCount("bar2") // `("bar2")` is optional and can be inferred from method name public void bar2() { ... } } AppEvent 重命名为 SysEvent, AppEventId 重命名为 SysEventId 支持 JAX-RS 方式定义 Controller Action Handler public class TestController { // Act Style @GetAction("foo") public String foo() {return "foo";} // JAX-RS style @GET @PATH("bar") public String bar() {return "bar";} } 支持 app secret 周期性变动 - 大大提高应用的安全性 增强事件机制 加载资源到更多的类型 public class Demo { @LoadResource("name.list") public List<String> nameList @LoadResource("name.list") public File nameListFile @LoadResource("name.list") public Set<String> uniqNameList; @LoadResource("pojo.json") public MyPojo myPojo; } 更多 act-1.7.0 的内容 ActFramework 1.7.0 - 1.8.1,高性能 Java Web 框架下载地址