- Description of the phenomenon, in the Tomcat environment, you can use: String path = Request.getsession (). Getservletcontext (). Getrealpath ("/") + "zjfxjk\\expertslib\ \photos\\ "; Get the server address and do the file operation. However, in the WebLogic environment, string path = Request.getsession (). Getservletcontext (). Getrealpath ("/") This is a null value, Then about the file upload operation background report null pointer exception
- Then try using string path = System.getproperty ("User.dir"). replace ("\ \", "/") + "/photos/"; Get disk path, but Chrome uses SRC to paste this address in JSP, the foreground error "not allowed to load local resource"
- Continue to modify, String path = new File (This.getclass (). getClassLoader (). GetResource ("/"). GetPath ()). Getparentfile (). Getparentfile (). GetAbsolutePath () + "/zjfxjk/expertslib/photos/"; After the address in the background is modified, everything is fine.
WebLogic javaweb path problem not allowed to load local resource