在侦听器类中,我要获取httpservletrequest对象:
public class MyEndpointInterceptorAdapter extends EndpointInterceptorAdapter {
@Autowired
private HttpServletRequest httpServletRequest;
...
}
我实际得到的是httpservletrequest的代理对象。
如何从这个代理spring对象中获取原始的httpservletrequest对象?
更新1:
这里的每个请求都是堆栈跟踪:java.lang.classcastexception:com.sun.proxy.$proxy622不能在weblogic.servlet.internal.servletrequestimpl.getoriginalrequest(servletrequestimpl)处强制转换为weblogic.servlet.internal.servletrequestimpl。java:1654)在weblogic.servlet.security.servletauthentication.runas(servletauthentication。java:726)在weblogic.servlet.security.servletauthentication.runas(servletauthentication。java:710)在weblogic.servlet.security.servletauthentication.runas(servletauthentication。java:681)在eu.cec.digit.ecas.client.authentication.abstractweblogic9servletauthentication.impersonate(abstractweblogic9servletauthentication。java:170)在eu.europa.ec.comp.cmr.iop.soap.security.interceptor.ecasticketauthenticationinterceptor.authenticateandimpersonate(ecasticketauthenticationinterceptor。java:107)在eu.europa.ec.comp.cmr.iop.soap.security.interceptor.ecasticketauthenticationinterceptor.handlerequest(ecasticketauthenticationinterceptor。java:89)在org.springframework.ws.server.messagedispatcher.dispatch(messagedispatcher。java:227)位于org.springframework.ws.server.messagedispatcher.receive(messagedispatcher。java:176)位于org.springframework.ws.transport.support.webservicesessagereceiverobjectsupport.handleconnection(webservicesessagereceiverobjectsupport)。java:89)在org.springframework.ws.transport.http.webservicemessagereceiverhandleradapter.handle(webservicemessagereceiverhandleradapter)。java:61)位于org.springframework.ws.transport.http.messagedispatcherservlet.doservice(messagedispatcherservlet。java:293)位于org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet。java:981)在org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet。java:884)在javax.servlet.http.httpservlet.service(httpservlet。java:707)位于org.springframework.web.servlet.frameworkservlet.service(frameworkservlet。java:858)在javax.servlet.http.httpservlet.service(httpservlet。java:790)在weblogic.servlet.internal.stubsecurityhelper$servletserviceaction.run(stubsecurityhelper)。java:286)在weblogic.servlet.internal.stubsecurityhelper$servletserviceaction.run(stubsecurityhelper。java:260)在weblogic.servlet.internal.stubsecurityhelper.invokeservlet(stubsecurityhelper。java:137)在weblogic.servlet.internal.servletstubimpl.execute(servletstubimpl。java:350)在weblogic.servlet.internal.tailfilter.dofilter(tailfilter。java:25)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在org.springframework.boot.actuate.web.trace.servlet.httptracefilter.dofilterinternal(httptracefilter。java:90)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在eu.europa.ec.comp.cmr.iop.soap.security.filter.exceptionhandlerfilter.dofilterinternal(exceptionhandlerfilter。java:23)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在org.springframework.web.filter.requestcontextfilter.dofilterinternal(requestcontextfilter。java:99)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在org.springframework.web.filter.httpputformcontentfilter.dofilterinternal(httpputformcontentfilter。java:109)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在org.springframework.web.filter.hiddenhttpmethodfilter.dofilterinternal(hiddenhttpmethodfilter。java:93)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在org.springframework.boot.web.servlet.support.errorpagefilter.dofilter(errorpagefilter。java:130)在org.springframework.boot.web.servlet.support.errorpagefilter.access$000(errorpagefilter。java:66)位于org.springframework.boot.web.servlet.support.errorpagefilter$1.dofilterinternal(errorpagefilter)。java:105)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在org.springframework.boot.web.servlet.support.errorpagefilter.dofilter(errorpagefilter。java:123)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)位于org.springframework.boot.actuate.metrics.web.servlet.webmvcmetricsfilter.filterandrecordmetrics(webmvcmetricsfilter)。java:117)在org.springframework.boot.actuate.metrics.web.servlet.webmvcmetricsfilter.dofilterinternal(webmvcmetricsfilter)。java:106)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在org.springframework.web.filter.characterencodingfilter.dofilterinternal(characterencodingfilter。java:200)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:107)在weblogic.servlet.internal.filterchainimpl.dofilter(filterchainimpl。java:78)在weblogic.servlet.internal.webappservletcontext$servletinLocationAction.wraprun(webappservletcontext。java:3701)在weblogic.servlet.internal.webappservletcontext$servletinLocationAction.run(webappservletcontext。java:3667)在weblogic.security.acl.internal.authenticatedsubject.doas(authenticatedsubject。java:326)在weblogic.security.service.securitymanager.runasforusercode(securitymanager。java:197)在weblogic.servlet.provider.wlssecurityprovider.runasforusercode(wlssecurityprovider。java:203)在weblogic.servlet.provider.wlssobjecthandle.run(wlssobjecthandle。java:71)在weblogic.servlet.internal.webappservletcontext.dosecuredexecute(webappservletcontext。java:2443)在weblogic.servlet.internal.webappservletcontext.securedexecute(webappservletcontext。java:2291)在weblogic.servlet.internal.webappservletcontext.execute(webappservletcontext。java:2269)在weblogic.servlet.internal.servletrequestimpl.runinternal(servletrequestimpl。java:1703)在weblogic.servlet.internal.servletrequestimpl.run(servletrequestimpl。java:1663)在weblogic.servlet.provider.containersupportproviderimpl$wlsrequestexecutor.run(containersupportproviderimpl。java:272)在weblogic.invocation.componentinvocationcontextmanager.\u运行方式(componentinvocationcontextmanager。java:352)在weblogic.invocation.componentinvocationcontextmanager.runas(componentinvocationcontextmanager。java:337)在weblogic.work.livepartitionutility.dorunworkundercontext(livepartitionutility。java:57)在weblogic.work.partitionutility.runworkundercontext(partitionutility。java:41)在weblogic.work.selftuningworkmanagerimpl.runworkundercontext(selftuningworkmanagerimpl。java:644)在weblogic.work.executethread.execute(executethread。java:415)在weblogic.work.executethread.run(executethread。java:355)
1条答案
按热度按时间sbdsn5lh1#
答案是,从spring在@autowired上返回的代理对象,您不能访问原始的httpservletrequest对象。
您可以通过以下不同的路径获取httpservletrequest对象:requestcontextholder
这将提供原始的httpservletrequest。