-
Notifications
You must be signed in to change notification settings - Fork 132
2:Router
gris.wang edited this page Nov 8, 2017
·
1 revision
使用RouterController来定义一个路由Controller类,RouterMapping用以指定Controller中每个具体的方法,RouterController+RouterMapping唯一匹配一个http请求的路由,RouterParam用以标识方法的参数,用以实现http请求参数的转换,基础类型的参数必须使用RouterParam注解进行标识,POJO对象可以不使用RouterParam标识。
@Bean() // 如果需要使用Autowired,则该类自身需要使用Bean注解标注
@RouterController(path="/UserController")
public class UserController {
@Autowired(name="userService")
private IUserService userService;
@RouterMapping(path="/getUserInfo",requestMethod=RequestMethod.GET,renderType=RenderType.JSON)
public BaseRender getUserInfo(UserBean userBean,@RouterParam(key="pid") Integer pid){
JSONObject object = new JSONObject();
object.put("user",userService.selectUserInfo(userBean.getId()));
object.put("pid",pid);
return new BaseRender(RenderType.JSON,object);
}
}