dropwizard 0.7 @会话注释

yaa*_*rix 3 java session dropwizard

我正在尝试让Dropwizard与会议合作。我已经读过0.7,Dropwizard添加了会话支持。来自发行说明:“增加了对HTTP会话的支持。将带注释的参数添加到资源方法:@Session HttpSession会话中,以注入会话上下文。”

我有一个示例资源类,它从http get请求获取用户/密码,并且我想在会话中保存用户名:

@GET
public Response auth(@QueryParam("user") String user, @QueryParam("password") String password,         @Session HttpSession session) throws URISyntaxException {
    URI rootUri = getApplicationRootUri();
    if(!user.equals(config.getUser()) || !password.equals(config.getPassword())) {

        return Response.temporaryRedirect(rootUri).build();
    }
    session.setAttribute("user", user);
    return Response.temporaryRedirect( new URI("/../index.html")).build();
}
Run Code Online (Sandbox Code Playgroud)

尝试从我的应用程序登录时,我得到:

ERROR [2014-05-17 10:33:45,244] com.sun.jersey.spi.container.ContainerRequest: A message body reader for Java class javax.servlet.http.HttpSession, and Java type interface javax.servlet.http.HttpSession, and MIME media type application/octet-stream was not found.
Run Code Online (Sandbox Code Playgroud)

我尝试从github上的dropwizard源中查找一些测试,似乎@Session注释的使用方式与我的代码相同。

有任何想法吗?

谢谢!

Lub*_*cin 5

在应用程序类中,我要做的是(dropwizard 0.7):

    environment.jersey().register(HttpSessionProvider.class);
    environment.servlets().setSessionHandler(new SessionHandler());
Run Code Online (Sandbox Code Playgroud)