[Original] How to open Word file online in Java development

This program uses PageOffice products to open Word documents online:

1. First download the product development kit from PageOffice official website, http://www.zhuozhengsoft.com/dowm/ , download PageOffice for JAVA 

2. Run the sample PageOffice product for reference:

  1) Copy the Samples4 folder to the Webapps directory of Tomcat,

  2)访问:http://localhost:8080/Samples4/index.html

3. Start the integration:

  1) Copy the lib folder in the "integration files" folder to the WEB-INF directory of your web project;

  2) Add the following configuration to your web.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) Write the calling code of PageOffice   in the background action access or RequestMapping method (such as the openWord method):

PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(request); 
poCtrl1.setServerPage( "poserver.zz"); // This line must be 
poCtrl1.setSaveFilePage("savefile.jsp"); // To save the file, this line must 
 // open the file 
poCtrl1.webOpen("doc/test. doc", OpenModeType.docNormalEdit, "Zhang San"); 
String poHtmlCode=poCtrl1.getHtmlCode("PageOfficeCtrl1");

  4). Insert the code in the body of the html code where the office interface needs to appear, or output the string returned by the poCtrl1.getHtmlCode method to the html page by other methods: 

<% = poHtmlCode %> 
or
<%=poCtrl1.getHtmlCode("PageOfficeCtrl1")%>

  5) Run the program to access the openWord method to open the word document online. If you have any questions, you can refer to http://localhost:8080/Samples4/index.html in the example: 1. 1. The easiest way to open and save Word files online (URL address method)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324843529&siteId=291194637