创建 Controller

src/main/java/hello/controllers 目录中创建 UserController 类:

package hello.controller;

import hello.model.User;
import hello.service.UserService;
import leap.core.annotation.Inject;
import leap.web.action.ControllerBase;
import leap.web.annotation.Path;
import leap.web.annotation.http.GET;

@Path("/user")
public class UserController extends ControllerBase {

    @Inject
    private UserService userService;

    @GET
    public User getHelloUser() {
        return userService.getHelloUser();
    }
}

这里的逻辑很简单,就是直接调用 UserService 对象处理请求。

上一篇:创建 Service 下一篇:运行测试

results matching ""

    No results matching ""