How do you add a static file to your setup server and then access it in your browser?

Spring – Thymeleaf:

Preconditions, the Spring-Thymeleaf project is already built.

Create a new abc. TXT file under static directory as shown below:

Then open http://localhost:8201/abc.txt in your browser.

Project address :gitee.com/tinytongton…

Tomcat:

Prerequisites The Tomcat service is set up.

Find the Tomcat installation directory and assign the abc.txt file to the webapps directory, as shown in the figure below:

But we still can’t access it at this time, we need to add some configuration. Open conf/server. XML and add a line to Host node. The result is as follows:

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> ... <! - access webapps/ABC. TXT file - > < Context path = "/" the docBase = "/ Users/user/Library/Tomcat/webapps/" reloadable =" true "debug =" 0" crossContext="true"/> </Host>Copy the code

Where path stands for relative path, the “/” I set directly stands for root directory; DocBase represents the actual directory of the resource. Your static resource, as long as it is in this directory, can be accessed by path + filename.

Set up before we start the Tomcat service, then visit http://localhost:8080/abc.txt.

Reference:

Tomcat installation on MAC, start and close script configuration, port number change

Accessing static resources (image files, etc.) through Tomcat configuration

Vue project

Create a test.json file in the public directory:

Then start the serviceyarn serve --port 9527“, enter in the browserhttp://localhost:9527/test.jsonYou can see it.Project Address:tinytongtong/frontend-demo

Reference: cn.vuejs.org/index.html