ServletActionContext.getServletContext () null pointer exception

Today when using ServletActionContext.getServletContext () to get servletContext, it is actually empty

I think it ’s incredible, I did n’t write this thing, I ’ve led it, and gave me a null pointer

I also checked it online, and the solution seems to be:

  Re-deploy the project without using eclipse's built-in browser, and switch to another third-party browser to access it, and then it really works

I don't know where the problem is, but someone explained:

  When accessing the browser, the browser automatically assigns a session id to the user. When the submission is made, the id is passed to the action or servlet. At that time, the session in the action or servlet has room for allocation. Therefore, when not directly accessed through the browser, when directly tested in the action or servlet, because the session does not get the session id, a null pointer exception is reported

Guess you like

Origin www.cnblogs.com/ibcdwx/p/12760812.html