我在tomcat中运行了一个非常简单的Jersey 2.x rest端点。对于到终点的每个请求,我得到这个日志输出:
FINE: Security checking request POST /myurl/s
Aug 28, 2015 7:17:08 AM org.apache.catalina.authenticator.AuthenticatorBase invoke
FINE: Not subject to any constraint
Aug 28, 2015 7:17:08 AM org.apache.catalina.core.StandardWrapper allocate
FINER: Returning non-STM instance
这是代码:
@Path("myurl")
public class MyEndPoint extends BaseRawInfoEndPoint {
@POST
@Path("s")
//@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public void saveStuff(String rawJson) throws JsonProcessingException {
//persist code
}
}
答案 0 :(得分:1)
您可以看到它已记录here。请求通过Tomcat的身份验证机制。如果没有设置约束,那么它将被记录,并且该方法将返回并继续。
安全性约束来自Servlet规范。您可以阅读更多相关信息here in the EE tutorial: 48.2.1 Specifying Security Constraints。约束是配置身份验证和访问控制机制,它们应该在web.xml文件中配置。
另见: