嗨,当我试图在浏览器上打开我的应用程序的登录页面时,我得到了这个异常。P.S :打开jdk zulu 11和通配符24进行部署。
org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: javax.servlet.http.HttpServletRequest
at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:77)
at javax.servlet.api@2.0.0.Final//com.sun.proxy.$Proxy163.getSession(Unknown Source)
at deployment.demo.ear.rest.war//com.demoapp.demo.rest.resources.Myclass.init(Myclass.java:107)
发布于 2022-06-03 16:59:15
根据我的经验,@Context
是按每种方法设置的。更像是:
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response myMethod(String someString, @Context HttpServletRequest request) {
通过这种方式,HttpServletRequest
是基于方法而不是基于类来设置的。我认为您不希望它出现在类级别上,就好像类有许多方法一样--这些方法不应该共享相同的HttpServletRequest
。
https://stackoverflow.com/questions/72489706
复制相似问题