Resourcebundle. getbundle ("myresource ")

Source: Internet
Author: User

If resourcebundle. getbundle ("myresource") cannot read the resource file, pay attention to the following issues.

1. Java Project

You only need to put the myresource. properties file under SRC. If it is under package, the filename of the program should be package/myresource
2. J2EE WEB Project

1, myresource. properties should be placed under the WEB-INF's classes,

2. If jar is used to read the resource file, the jar must be added under Lib, not just the classpath configured by IED (eclipse ).

Explanation: When the getbundle loads the resource file, it will read the classloader of the current application, traverse the current classloader to find the classpath, and bind the resource file. If it cannot be found, it will report

Java. util. missingresourceexception.

The key is that if you use eclipse to configure the application and host lib to Elipse for loading, when Tomcat is started in eclipse, the classloader and

Tomcat does not load the same class after reading the application.

When Tomcat is started, load the application according to the JRE configured by Tomcat. In addition, the application Lib is hosted on eclipse, and the jar under Lib is loaded by the JRE set by Elipse. There will be two JRE environments.

Solution: put all the jar files under the Lib of the WEB-INF and load them by the container. Of course, it is also required to load it to classpath.


Related Keywords:

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.