2017-11-09 09:06

@JFinal tks 波大大百忙抽空答疑我的问题,由于回复不能贴图,我大概描述一下我的实现方案和一些疑问:
1.public abstract class BaseController> extends Controller{...}

2.public class BlogController extends BaseController {
public void prepare() throws Exception{
if(id != null){
entity = Blog.dao.findById(id);
}else{
entity = new Blog();
}
}

public void index(){//请求此action
renderText(""+id);
}

3.public void intercept(Invocation inv) {
System.out.println("Before invoke");

// BaseController bc = inv.getController(); //error: incompatible,我这里有点不明白为什么无法转换, 而getTarget就直接可以

BaseController bc = inv.getTarget();

bc.setId(inv.getController().getParaToLong("id"));
try {
bc.prepare();
} catch (Exception e) {
e.printStackTrace();
}

inv.invoke();//以上申明 bc 变量来达到在调用目标方法时,能够获取到 id,entity等预执行的变量
System.out.println("after invoke");
}

以上。。。我用以上的方式实现了prepare功能,但总觉得有点不简洁,或者有更好的方法,望波大大指点一二,再者,很期待3.3版本的问世。。。。。。。本来是在凌晨1:30左右发出的,结果被拒绝了。。。。

2017-11-01 15:50

社区的搜索功能什么时候有,社区帖子越来越多了,没搜索不方便