First, material preparation
Baidu a bit: pageoffice, download pageoffice for Java from the official website. Compress package Files:
Second, the implementation of the steps:
1. Open the "Integrated files" directory and copy the Pageoffice4.4.0.2.jar from the "web-inf\lib" directory to your project's "Web-inf\lib" directory
2. Refer to the Web. xml file in the "Integrated Files" folder to configure the website. xml file in your project, or you can add the following configuration directly to your XML;
<!--Pageoffice Begin - <servlet> <Servlet-name>Poserver</Servlet-name> <Servlet-class>Com.zhuozhengsoft.pageoffice.poserver.Server</Servlet-class> </servlet> <servlet-mapping> <Servlet-name>Poserver</Servlet-name> <Url-pattern>/poserver.zz</Url-pattern> </servlet-mapping> <servlet-mapping> <Servlet-name>Poserver</Servlet-name> <Url-pattern>/sealsetup.exe</Url-pattern> </servlet-mapping> <servlet-mapping> <Servlet-name>Poserver</Servlet-name> <Url-pattern>/posetup.exe</Url-pattern> </servlet-mapping> <servlet-mapping> <Servlet-name>Poserver</Servlet-name> <Url-pattern>/pageoffice.js</Url-pattern> </servlet-mapping> <servlet-mapping> <Servlet-name>Poserver</Servlet-name> <Url-pattern>/jquery.min.js</Url-pattern> </servlet-mapping> <servlet-mapping> <Servlet-name>Poserver</Servlet-name> <Url-pattern>/pobstyle.css</Url-pattern> </servlet-mapping> <!--Pageoffice End -
3. On the page that displays the file list (for example: doclist.jsp), add a reference to the Pageoffice.js file and open the hyperlink for the file "open Word online":
<script type= "Text/javascript" src= "jquery.min.js" ></script> <script type= "Text/javascript" src= " Pageoffice.js "id=" Po_js_main "></script>
......
<a href= "javascript:POBrowser.openWindowModeless (/word.jsp ', ' width=1200px;height=800px; ');" > Open word</a> Online
4. Add the import package on the page that invokes the Pageoffice product (for example: word.jsp): com.zhuozhengsoft.pageoffice.*
5. Write the Pageoffice call code, open the file online (for example: Server D packing directory 1.doc):
New Pageofficectrl (request); Poctrl1.setserverpage (// poctrl1.setsavefilepage ("savefile.jsp"); to save the file, this line must //
6. Insert the following code where the Office interface needs to appear in the body of the HTML code:
<% = Poctrl1.gethtmlcode ("PageOfficeCtrl1") %>
7. Add code to process the file save in the action method or Requestmapping method or JSP page where the file is stored (for example: savefile.jsp):
Filesaver fs=New filesaver (request,response); Fs.savetofile ("D:\\1.doc"); Fs.close ();
8. Start the Run project, access the File list page (for example: doclist.jsp), click the "open Word online" hyperlink to view the effect of online open edit saving Word file.
Iii. References and examples
1. Deployment Pageoffice Example: Copy the Samples4 folder to the Webapps directory of Tomcat, Access: http://localhost:8080/Samples4/index.html
2. Refer to the basic function example: one, 2, open the Office file as a disk path (for example in Word)
[Original]java Open online for Word documents