搭建自定义工程及开发-获取不到用户信息
背景:因为现有接口企业微信的考勤数据只有管理员账户可以调用,只好自己弄一个,获取当前用户的企业微信考勤。
参考:https://www.yuque.com/o2oa/course/tuef8c
版本:6.4.4
问题:当前用户信息一直是Anonymous
相关代码:
JaxrsServicePathFilter.java 中设置了需要登陆才能访问
@WebFilter(urlPatterns = { "/servlet/*", "/jaxrs/qywxAttendance/*", }, asyncSupported = true)
public class JaxrsServicePathFilter extends CipherManagerUserJaxrsFilter {
}
Action 类中 定义了 EffectivePerson effectivePerson = this.effectivePerson(request);
@Path("expand/qywxAttendance")
@JaxrsDescribe("企业微信考勤")
public class QywxAttendanceDetailAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(QywxAttendanceDetailAction.class);
@JaxrsMethodDescribe(value = "列示当前用户/指定用户的企业微信打卡记录,分页..", action = ActionListPaging.class)
@POST
@Path("list/paging/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
@JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size, JsonElement jsonElement) {
ActionResult<List<ActionListPaging.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
System.out.println(this.effectivePerson(request).toString());
try {
result = new ActionListPaging().execute(effectivePerson, page, size, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
}
}
通过System.out.println(this.effectivePerson(request).toString()); 输出后,结果如下
理论上来说,必须要登陆才能访问,用户信息肯定是有的,就是不知道没获取到
您web上访问这个服务的时候,可以f12先看一下,是否有x-token。
或者说,您从哪里触发的这个服务的打印?
从现在的截图上看,现在访问服务是没有用户登录的情况。 找到问题了,JaxrsServicePathFilter.java 中的路径和action文件的路径不一致导致的 xuannan 发表于 2021-11-29 14:55
找到问题了,JaxrsServicePathFilter.java 中的路径和action文件的路径不一致导致的
:handshake
页:
[1]