【发布时间】:2018-07-29 22:16:18
【问题描述】:
没有记录在 DropWizard 1.0.x 中配置和(取消)引用 HttpSessions 的正确方法。是怎么做到的?
this question 涵盖了 0.7.x 和 0.8.x 版本,但似乎情况发生了变化,因为引用的某些类不是 1.0.x 的一部分。
【问题讨论】:
标签: session dropwizard
没有记录在 DropWizard 1.0.x 中配置和(取消)引用 HttpSessions 的正确方法。是怎么做到的?
this question 涵盖了 0.7.x 和 0.8.x 版本,但似乎情况发生了变化,因为引用的某些类不是 1.0.x 的一部分。
【问题讨论】:
标签: session dropwizard
你不需要带有不可用的类的行,或者 Spring Boot。
environment.jersey().register(HttpSessionProvider.class);environment.servlets().setSessionHandler(new SessionHandler());
那么,例如:
@GET
@Path("/email")
@Produces(MediaType.TEXT_PLAIN)
public Response getSessionEmail(@Context HttpServletRequest request) {
return Response.ok(request.getSession().getAttribute("email")).build();
}
【讨论】:
new SessionHandler() ?
算了,用 Spring Boot。
Spring 保留了前端技术的传统,更适合自然需要会话的任何事物。
【讨论】: