[英]FlexContext.getServletContext() is returning NPE
I'm having an issue with Flex. 我在Flex上遇到问题。
The following java line is throwing NPE. 以下Java行抛出NPE。
ServletContext servletContext = FlexContext.getServletContext();
However, the following command works just fine and throws no exception. 但是,以下命令可以正常工作,并且不会引发异常。 After the command executes, httpServletRequest is null (as expected).
命令执行后,httpServletRequest为空(如预期)。
HttpServletRequest httpServletRequest = FlexContext.getHttpRequest();
I was able to find the answer. 我找到了答案。 I think that Flex pulled an abstraction on us.
我认为Flex对我们进行了抽象。 I think that getServletContext() actually calls FlexContext.getServletConfig() within the method.
我认为getServletContext()实际上在方法中调用FlexContext.getServletConfig()。 Because of this internal call, when Flex then internally calls getServletContext (), the method throws NPE.
由于此内部调用,因此当Flex然后内部调用getServletContext()时,该方法将引发NPE。
I simply altered the code to the following. 我只是将代码更改为以下内容。
ServletConfig servletConfig = FlexContext.getServletConfig();
if (servletConfig != null) {
ServletContext servletContext = servletConfig.getServletContext();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.