Struts2 take web-inf files.

Source: Internet
Author: User

In a lot of business to get web-inf files.

There are a lot of people on the Internet asked this situation how to get files, there are many people suggest that the file in Src, personal feeling that this dude fart.

Provides a method here.

This is the way to use struts.

Properties Properties = new properties ();
			try {
				//Get current path
				String url = This.getclass (). GetResource (""). GetPath ()
						. ReplaceAll ("%20", "");
				Get web-inf path
				String path = url.substring (0, Url.indexof ("Web-inf"))
						+ "web-inf/sysconfig.properties";
				Read prop file
				properties.load (new FileInputStream (path));
			\ catch (IOException e) {
				//E.printstacktrace () ;
			}

As soon as the path is found, any file is a cinch.



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.