2020-07-23 14:57
@xialinlin
AppConfig继承JFinalConfig
@Override
public void configRoute(Routes me) {
me.setMappingSuperClass(false);
me.add(new AdminRoute());
}
AdminRoute继承Routes
@Override
public void config() {
// 配置路由拦截器
addInterceptor(new AdminInterceptor());
// 配置拦截路由
add("/user", UserController.class);
}
AdminInterceptor实现Interceptor
public void intercept(Invocation inv) {
System.out.println("AdminInterceptor: Before method invoking");
inv.invoke();
System.out.println("AdminInterceptor: After method invoking");
}
UserController继承JbootController
@ActionKey("/user/list")
public void users() {
renderJson(userService.findAll());
}
按理说controller可以不用加@RequestMapping,但是不加根本就进不来这个action,直接404,不管加不加总之配置类没起作用