Tomcat built-in browser to access the server through SpringBoot file

  EDITORIAL : comes a new demand, requiring previews on h5 pdf, had asked me to write front-end, but unfortunately I Daoxing too shallow front-end (in fact, also the back-end shallow), toss a day pdf.js, did not result. On the project manager for a disappointment, how kind of reaction is: Forget it, you go and do it back-office services. Then I will have a new demand: a return address to the front, you can open PDF files on the server directly.

  Behind EDITORIAL : If you can open the file directly with the address, then we can configure the virtual path on the web server, you can directly access the files. If with ftp is also OK, but I'm not familiar with. Let me split from the dawn he began to record my entire implementation process, after all, I spent a lot of time

 


 

In order to verify this first program it is achievable, I first downloaded tomcat8 first test.

1. Configure Web Hosting

  Open conf / server.xml in the installation directory, add the following content.

<Context docBase ="C:\PDF\" path ="/pdf" debug ="0" reloadable ="true"/>

  

 

 

   docBase: Computer real directory path: the path mapped

2. Start tomcat

  In the bin directory, double-click on one of the two documents can be

  

 

 3. Verify

  Take a look at where the path to the file, the file is real.

  

 

   After starting the tomcat, in the browser enter http: // localhost: 8080 / pdf / fool recipes --80 after cooking does not have dedicated .pdf

  

 

 It is perfect.

 

Then we have got down to business, and did not install the tomcat server, using the built-in SpringBoot tomcat, so we built what is necessary to configure tomcat virtual host configuration file at boot

  

 

 I detailed configuration introduced here is not talked about, because I do not understand Haha, reference blog: https://liuyanzhao.com/7599.html .

Then on the same subject, after starting the project, the browser input  http: // localhost: 8071 / fool recipes --80 after cooking does not have dedicated .pdf  can see pdf file opened. If the program is uploaded to the server, pay attention to changes ip and port. Also note that we now see me write my real directory in the C: \ PDF, because my computer and server are Windows systems, the use of Linux servers students to pay attention, directory write right.

 


 

 

Written in the last: At this point, now we just need to write interfaces, use the File class to traverse C: \ files in PDF \ directory, and then preceded by the agreement, ip, port, URI string to form a complete return to the front, they can use this address to complete preview of the PDF. Article bit basis, because before I really do not understand, to be a record, and I have always believed that any technical field, are basically the core of things. good night!

 

 

 

 

Guess you like

Origin www.cnblogs.com/studentc/p/11870257.html