WebLogic javaweb path problem not allowed to load local resource

Source: Internet
Author: User
  • 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.