I'm having an issue with Flex.
The following java line is throwing 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 = FlexContext.getHttpRequest();
I was able to find the answer. I think that Flex pulled an abstraction on us. I think that getServletContext() actually calls FlexContext.getServletConfig() within the method. Because of this internal call, when Flex then internally calls getServletContext (), the method throws NPE.
I simply altered the code to the following.
ServletConfig servletConfig = FlexContext.getServletConfig();
if (servletConfig != null) {
ServletContext servletContext = servletConfig.getServletContext();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.