SPRING-MVC accessing local HTML files

Source: Internet
Author: User

To preview the Word document online, just start thinking about turning Word into a PDF file and then opening the PDF document directly in the browser.

But the project was deployed under Linux, and searching the internet did not find a suitable method,

Later, the project group discussed generating HTML files with POI, but the generated HTML documents were generated in an extra way, and the browser was unable to directly access the POI generated HTML files.

Not allowed to load local resource: file:///D:/images/word/media/image1.png

This error is plainly to the whole.

Later try

                  out =response.getoutputstream ();                Response.setheader ("Pragma", "No-cache");                   Response.setheader ("Cache-control", "No-cache");                  Response.setdateheader ("Expires", 0);                  Text/html;charset=utf-8 " );                   Xhtmlconverter.getinstance (). Convert (document, out, options);                    Out.flush ();                   Out.close ();

HTML files can be displayed on the page, but the images inside are still not visible. 404 and gave me the whole understanding, because the deployment of the project is not these pictures, completely wishful thinking.

No way, consulting project The Great God, the great God is the great God, the brain is not filmed on a way to think.

————————————————————

In the Springmvc-servlet.xml configuration file

Mvc:resources is the loading of static files

See

Https://www.cnblogs.com/linnuo/p/7699401.html

Add in the Pringmvc-servlet.xml file in the project

  <mapping= "/wordview/**"  location= "file:d:/poitransforms/" />

Put the HTML file in a fixed d:/poitransforms/, folder can have a subset folder, the subfolder name can be a custom uuid,

My Side click the Preview button is the popup window embedded an iframe, the iframe src path is:

Util.getpath () + '/wordview/temp/5570c3fba83f464fa383e58cd394f860/transforms.html '

Another: _________________________________________________________________

Get Project Name
Getpath:function () {
Return Location.pathname.match (/\/(. +?) (? =\/)/g) [0];
}

Temp/5570c3fba83f464fa383e58cd394f860/transforms.html This string is returned to the foreground of the generated HTML file path, is fixed in the d:/poitransforms/

So write it all alive, and then delete d:/poitransforms/.

SPRING-MVC accessing local HTML files

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.