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