mvc整合pageoffice

2016-08-21 12:35:10 u013604967 阅读数 868

 

1. JSAAS简介

 

JSAAS企业应用平台是一款带有企业信息化基础管理的Saas开发平台框架,它是基于流行的轻量级框架Spring上构建,以支持中小企业、大型集团企业、政府单位的日常事务管理,平台提供基础的数据交互功能模块、文档处理管理模块、组织架构管理模块、流程管理模块、企业公告、微信交互管理模块等,适合于有IT研发能力的大型企业或向Saas应用运维的IT开发企业。同时整合了Activiti流程,并且进行扩展以支持国内流程的需求,可以有效满足企业或部门的OA办公或BPM业务需求。

 

其平台架构如下所示:



 

平台的使用价值:



 

 

平台的流程业务支持:

 



 
 

 

2. 整合开源技术

 

  • JAVA 1.6 +
  • Spring Core核心容器
  • Spring  MVC 4
  • Spring AOP
  • Spring Security
  • Groovy动态脚本语言
  • MiniUI前端JS框架
  • Jquery javascrip库
  • MyBatis Or JDBC数据持久层框架
  • Maven版本控制
  • Log4j Java XML API
  • Scheduling Quartz定时任务 
  • Alfresco Activiti 5
  • JQuery
  • Ueditor
  • Code Mirror
  • PageOffice
  • Google Calender
  • Jquery Ystep
  • 其他控件等

 

 

3. 传统应用开发支持

 

 

JSAAS是一款可以开发政府办公应用、业务流程系统、企业OA、企业的业务管理系统等、它基于以下开源框架上构建,因此,对于JAVA的开发人员来说,这是一款容易上手的

开发框架,特别是流程业务的支持,所以在开发传统的业务系统时,它会更加节省你的开发成本,结合外围开放的接口,可以有效支持多种端的接入,如手机端、微信端等。

虽然市面上有比较多的以下系统,但很多业务未必适合一些企业使用,定制开发自身的业务更加适合企业。

 

CRM(客户关系管理)

OA (协同管理)

ERP(企业应用管理)

KMS(知识管理)

HRM(人力资源管理)

DRP(分销应用管理)

 

4. 云应用或租户应用的支持

 

目前云应用是非常火的,JSAAS通过对组织架构及业务数据的逻辑划分,可以支持小规模的云端应用,而对于大模规的数据的云端应用,平台通过扩展应用服务器及数据库实例,以可以支持更大更快更安全的数据访问。

 

 

在云端应用上,我们可以构建以下应用:
 

JSAAS_680

如我们基于JSAAS上可以开发企业的协同平台,其访问例子如下:

 

http://www.redxun.cn:8020/saweb/index.do

 

系统界面如下所示:

 

 

jsaas-ent

 

 

5. 开放开源-社区版本供学习

 

 目前红迅软件推出开源社区版,并且提供开发学习讲解视频。满足开发人员对平台设计思想的理解、同时可以基于上面开发自身的业务应用。我们同时为同行企业或有开发能力的企业提供全开源的企业版,推进与合作伙伴深入合作,构建企业私有云与公有云应用。

 

 

  • 开源版源代码下载

 https://pan.baidu.com/s/1pLKp9V1

 

获取密码请发邮件至3102760881@qq.com

 

 

  • 学习视频

 1开发环境及代码生成器

 

2.生成器生成的代码讲解

 

3.组织架构讲解及开发讲解

 

4.组织架构数据结构分析

 

5.流程定义设计及表单设计

 

6.流程解决方案设计与分析

 

  • 部分在线文档讲解

http://www.redxun.cn/?cat=49

 

  • Wiki文档



 

1.如何实现Activiti的分支条件的自定义配置

2.Activiti的自定义组织架构及在流程中的应

3.Activiti如何实现流程的回退

4.JSAAS如何让外部业务功能参与Activiti流程的审批

5.JSAAS的Activiti会签开发扩展处理

6.Activiti的全局事件机制及其监听处理

 

 

 

 

 

2019-09-14 14:38:49 weixin_41043145 阅读数 391

1、整合注意事项

(1)查看不同MyBatis版本整合Spring时使用的适配包;

(2)下载整合适配包

https://github.com/mybatis/spring/releases

(3)官方整合示例,jpetstore

https://github.com/mybatis/jpetstore-6

2、整合思路、步骤

(1)搭建环境

​ 创建一个动态的WEB工程

​ 导入SSM需要使用的jar包

​ 导入整合适配包

​ 导入其他技术的一些支持包 连接池 数据库驱动 日志…

(2)Spring + Springmvc

​ 在web.xml中配置: Springmvc的前端控制器 实例化Spring容器的监听器 字符编码过滤器 REST 过滤器

​ 创建Spring的配置文件: applicationContext.xml:组件扫描、 连接池、 事务…

​ 创建Springmvc的配置文件: springmvc.xml : 组件扫描、 视图解析器 mvc:...

(3)MyBatis

​ 创建MyBatis的全局配置文件

​ 编写实体类 Mapper接口 Mapper映射文件

(4)Spring + MyBatis

​ MyBatis的 SqlSession的创建 .

​ MyBatis的 Mapper接口的代理实现类

(5)测试: REST CRUD

​ 查询所有的员工信息,列表显示

3、整合的配置

3.1 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
 <!-- 字符编码过滤器 -->
 <filter>
 	<filter-name>CharacterEncodingFilter</filter-name>
 	<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
 	<init-param>
 		<param-name>encoding</param-name>
 		<param-value>UTF-8</param-value>
 	</init-param>
 </filter>
 <filter-mapping>
 	<filter-name>CharacterEncodingFilter</filter-name>
 	<url-pattern>/*</url-pattern>
 </filter-mapping>
 
 <!-- REST 过滤器 -->
 <filter>
 	<filter-name>HiddenHttpMethodFilter</filter-name>
 	<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
 </filter>
 <filter-mapping>
 	<filter-name>HiddenHttpMethodFilter</filter-name>
 	<url-pattern>/*</url-pattern>
 </filter-mapping>
 
<!-- 实例化SpringIOC容器的监听器 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>

	<listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
 
 <!-- Springmvc的前端控制器 -->
	<servlet>
		<servlet-name>springDispatcherServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:springmvc.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>springDispatcherServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>

3.2 Spring 配置


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
	xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
	
	<!-- 组件扫描 -->
	<context:component-scan base-package="com.baidu.ssm">
		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
	</context:component-scan>
	
	<!-- 连接池 -->
	<context:property-placeholder location="classpath:db.properties"/>
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="${jdbc.driver}"></property>
		<property name="jdbcUrl" value="${jdbc.url}"></property>
		<property name="user" value="${jdbc.username}"></property>
		<property name="password" value="${jdbc.password}"></property>
		
	</bean>
	
	<!-- 事务 -->
	<bean id="dataSourceTransactionManager" 
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	<tx:annotation-driven transaction-manager="dataSourceTransactionManager"/>
</beans>

3.3 SpringMVC配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
  <!-- 组件扫描 -->
  <context:component-scan base-package="com.baidu.ssm" use-default-filters="false">
	  <context:include-filter type="annotation" 
         expression="org.springframework.stereotype.Controller"/>
  </context:component-scan>
   <!--视图解析器 -->
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
	<property name="prefix" value="/WEB-INF/views/"></property>
	<property name="suffix" value=".jsp"></property>
   </bean>

   <mvc:default-servlet-handler/>
   <mvc:annotation-driven/>
</beans>

3.4 MyBatis配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
	<!--  Spring 整合 MyBatis 后, MyBatis中配置数据源,事务等一些配置都可以
         迁移到Spring的整合配置中。MyBatis配置文件中只需要配置与MyBatis相关
         的即可。
	 -->
	 <!-- settings: 包含很多重要的设置项 	-->
	   <settings>
	 	<!-- 映射下划线到驼峰命名 -->
	 	<setting name="mapUnderscoreToCamelCase" value="true"/>
	 	<!-- 设置Mybatis对null值的默认处理 -->
	 	<setting name="jdbcTypeForNull" value="NULL"/>
	 	<!-- 开启延迟加载 -->
	 	<setting name="lazyLoadingEnabled" value="true"/>
	 	<!-- 设置加载的数据是按需还是全部 -->
	 	<setting name="aggressiveLazyLoading" value="false"/>	
	 	<!-- 配置开启二级缓存 -->
	 	<setting name="cacheEnabled" value="true"/>
	 </settings>
</configuration>

3.5 Spring整合Mybatis配置

<!-- Spring 整合 Mybatis -->
	<!--1. SqlSession  -->
	<bean class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 指定数据源 -->
		<property name="dataSource" ref="dataSource"></property>
		<!-- MyBatis的配置文件 -->
		<property name="configLocation" 
                 value="classpath:mybatis-config.xml"></property>
		<!-- MyBatis的SQL映射文件 -->
		<property name="mapperLocations" 
                 value="classpath:mybatis/mapper/*.xml"></property>
		<property name="typeAliasesPackage" 
                 value="com.baidu.ssm.beans"></property>
	</bean>
	<!-- Mapper接口
		MapperScannerConfigurer 为指定包下的Mapper接口批量生成代理实现类.bean的默认id是接口名首字母小写. 
	 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.baidu.ssm.mapper"></property>
	</bean>
	<!-- <mybatis-spring:scan base-package="com.baidu.ssm.mapper"/> -->


4、整合测试

(1)编写页面,发送请求:http://localhost:8080/ssm

(2)编写Handler,处理请求,完成响应

(3)在页面中获取数据,显示数据

5、整合案例(详细代码)

5.1 环境准备

(1)创建动态web工程并导入jar包

com.springsource.net.sf.cglib-2.2.0.jar

com.springsource.org.aopalliance-1.0.0.jar

com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar

spring-aop-4.0.0.RELEASE.jar

spring-aspects-4.0.0.RELEASE.jar

log4j.jar

mybatis-3.4.1.jar

mybatis-spring-1.3.0.jar

mysql-connector-java-5.1.37-bin.jar

druid-1.1.9.jar

jsqlparser-0.9.5.jar

pagehelper-5.0.0.jar

spring-beans-4.0.0.RELEASE.jar

spring-context-4.0.0.RELEASE.jar

spring-core-4.0.0.RELEASE.jar

spring-expression-4.0.0.RELEASE.jar

commons-logging-1.1.3.jarspring-jdbc-4.0.0.RELEASE.jar

spring-orm-4.0.0.RELEASE.jar

spring-tx-4.0.0.RELEASE.jar

spring-web-4.0.0.RELEASE.jar

spring-webmvc-4.0.0.RELEASE.jar

taglibs-standard-impl-1.2.1.jar

taglibs-standard-spec-1.2.1.jar

(2)db.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/study?characterEncoding=utf8
jdbc.username=root
jdbc.password=123456
(3)log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
 
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
 
 <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
   <param name="Encoding" value="UTF-8" />
   <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%-5p %d{MM-dd HH:mm:ss,SSS} %m  (%F:%L) \n" />
   </layout>
 </appender>
 <logger name="java.sql">
   <level value="debug" />
 </logger>
 <logger name="org.apache.ibatis">
   <level value="info" />
 </logger>
 <root>
   <level value="debug" />
   <appender-ref ref="STDOUT" />
 </root>
</log4j:configuration>

5.2 配置web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
 	<!-- 字符编码过滤器 -->
	<filter>
		<filter-name>characterEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<!-- 指定字符编码 -->
		<init-param>
			<param-name>encoding</param-name>
			<param-value>utf-8</param-value>
		</init-param>
		<!-- 解决响应的编码 -->
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>characterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!-- 处理Rest请求风格的过滤器 -->
	<filter>
		<filter-name>hiddenHttpMethodFilter</filter-name>
		<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>hiddenHttpMethodFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<!-- Spring监听器 :监听ServletContext对象,在服务器启动阶段,ServletContext对象会被创建,
		监听器中的方法会被执行,创建Spring容器-->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<!-- SpringMVC中央调度器 -->
	<servlet>
		<servlet-name>springDispatcherServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring-mvc.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>springDispatcherServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>

5.3 Javabean

package com.baidu.ssm.beans;

public class Employee {
	private Integer id;
	private String lastName;
	private String gender;
	private String descr;
	
	private Department dept;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getDescr() {
		return descr;
	}

	public void setDescr(String descr) {
		this.descr = descr;
	}

	public Department getDept() {
		return dept;
	}

	public void setDept(Department dept) {
		this.dept = dept;
	}

	@Override
	public String toString() {
		return "Employee [id=" + id + ", lastName=" + lastName + ", gender=" + gender + ", descr=" + descr + ", dept="
				+ dept + "]";
	}
	
	
}

package com.baidu.ssm.beans;

public class Department {
	
	private Integer id;
	private String deptName;
	
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	@Override
	public String toString() {
		return "Department [id=" + id + ", deptName=" + deptName + "]";
	}
	
	
}

5.4 mapper层(dao层)

package com.baidu.ssm.mapper;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.baidu.ssm.beans.Employee;
@Repository
public interface EmployeeMapper {
	
	/**
	 * 查询所有员工的信息以及部门的信息
	 */
	List<Employee>  getEmployeeAll();

}

5.5 配置SQL映射文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper SYSTEM "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.baidu.ssm.mapper.EmployeeMapper">
  	<select id="getEmployeeAll" resultMap="getAll">
  		select e.id eid,last_name,gender,descr,e.dept_id,d.dept_name
  		from tbl_employee e,tbl_department d
  		where e.dept_id = d.id
  	
  	</select>
  	
  	<resultMap type="employee" id="getAll">
  		<id column="eid" property="id"/>
  		<result column="last_name" property="lastName"/>
  		<result column="gender" property="gender"/>
  		<result column="descr" property="descr"/>
  		<association property="dept" javaType="department">
  			<id column="id" property="id"/>
  			<result column="dept_name" property="deptName"/>
  		</association>
  	
  	</resultMap>
</mapper>

5.6 service层

package com.baidu.ssm.service;

import java.util.List;

import com.baidu.ssm.beans.Employee;

public interface EmployeeService {
	
	List<Employee> getEmployeeAll();
}

package com.baidu.ssm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baidu.ssm.beans.Employee;
import com.baidu.ssm.mapper.EmployeeMapper;
import com.baidu.ssm.service.EmployeeService;

@Service
public class EmployeeServiceImpl implements EmployeeService{

	@Autowired
	private EmployeeMapper employeeMapper;
	
	
	@Override
	public List<Employee> getEmployeeAll() {
		return employeeMapper.getEmployeeAll();
	}
	
	
}

5.7 controller层

package com.baidu.ssm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.baidu.ssm.beans.Employee;
import com.baidu.ssm.service.EmployeeService;

@Controller
public class EmployeeController {
	
	@Autowired
	private EmployeeService employeeService;
	
	@RequestMapping(value="emps",method=RequestMethod.GET)
	public String getAllEmps(Model model) {
		
		//调用service层的方法
		List<Employee> emps = employeeService.getEmployeeAll();
		
		//将查询到的emps模型数据添加到model中
		model.addAttribute("emps", emps);
		return "list";
	}
}

5.8 配置applicationContext.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

	
	<!-- 组件扫描 -->
	<context:component-scan base-package="com.baidu.ssm">
		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
	</context:component-scan>
	<!--加载属性文件  -->
	<context:property-placeholder location="classpath:db.properties"/>
	
	<!-- 配置数据源 -->
	
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName" value="${jdbc.driver}"/>
		<property name="url" value="${jdbc.url}"/>
		<property name="username" value="${jdbc.username}"/>
		<property name="password" value="${jdbc.password}"/>	
	</bean>
	<!--配置事务管理器  -->
	<bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"/>
	</bean>
	<!-- 开启事务注解 -->
	<tx:annotation-driven transaction-manager="dataSourceTransactionManager"/>
	
	<!-- 配置sqlsessionFactory -->
	<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
		<!--使用数据源  -->
		<property name="dataSource" ref="dataSource"></property>
		
		<!-- 读取mybatis的主配置文件 -->
		<property name="configLocation" value="classpath:mybatis-conf.xml"/>
		
		<!-- MyBatis的SQL映射文件 -->
		<!-- <property name="mapperLocations" ref=""></property> -->
	</bean>
	
	<!-- 配置扫描接口 -->
	<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.baidu.ssm.mapper"></property>
	</bean>
	
</beans>

5.9 配置spring-mvc.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

	<!-- 组件扫描 -->
	<context:component-scan base-package="com.baidu.ssm" use-default-filters="false">
	
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
	</context:component-scan>
	
	<!-- 视图解析器 -->
	<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/views/"/>
		<property name="suffix" value=".jsp"/>
	</bean>
	
	<!-- 静态资源处理器 -->
	<mvc:default-servlet-handler/>
	
	<!-- 开启springmvc的注解支持 -->
	<mvc:annotation-driven/>

</beans>

5.10 配置mybatis的主配置文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<!-- Mybatis主配置文件|全局配置文件 -->
<configuration>
	

	<settings>
		<!-- 将数据库下划线命名方式映射为java的驼峰命名法 -->
		<setting name="mapUnderscoreToCamelCase" value="true"/>
		<!-- 开启延迟加载 -->
		<setting name="lazyLoadingEnabled" value="true"/>
		<!-- 设置加载的数据是按需还是全部 -->
		<setting name="aggressiveLazyLoading" value="false"/>
	</settings>
	
	<!-- 取别名 -->
	<typeAliases>
		
		<!-- 给指定包下的所有类取别名 默认的别名就是类名-->
		<package name="com.baidu.ssm.beans"/>
	</typeAliases>

	
	<!-- 
		Mapper映射器
			-引入SQL映射文件,Mapper映射文件
			-resource:去类路径下加载文件
			-url:引入网络路径或者是磁盘路径下的文件
			-
	-->
			
	<mappers>
		
		<!-- 批量注册 -->
		<package name="com.baidu.ssm.mapper"/>
	</mappers>
	
</configuration>

5.11 创建index.jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>人事管理系统的入口</title>

</head>
<body>
	<h2 align="center">欢迎来到人事管理系统页面</h2>
	<hr>
	<a style="text-align: center" href="${pageContext.request.contextPath }/emps">进入人事管理系统</a>
</body>
</html>

5.12 创建list.jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h2 align="center">欢迎进入人事管理系统</h2>
	<br>
	<hr>
	<h3 align="center">所有员工进行显示</h3>
	<table border="1" cellpadding="10" cellspacing="0" align="center">
		<tr>
			<th>员工编号</th>
			<th>员工姓名</th>
			<th>员工性别</th>
			<th>员工描述</th>
			<th>所在部门</th>
			<th>操作</th>
		</tr>
	<c:forEach items="${emps}" var="emp">
		<tr align="center">
			<td>${emp.id}</td>
			<td>${emp.lastName}</td>
			<td>${emp.gender}</td>
			<td>${emp.descr }</td>
			<td>${emp.dept.deptName}</td>
			<td>
				<a href="#">修改</a>
				<a href="#">删除</a>
			</td>
			
		</tr>
	
	</c:forEach>
		
	<tr align="center">
		<td colspan="7" >
			<a href="#">添加员工</a>
		</td>
	</tr>	
	
	</table>
</body>
</html>

5.13 效果

在这里插入图片描述

2016-03-28 13:33:08 Erris 阅读数 9731

最近需要项目用到在线打开word和excel文档处理,在PageOffice官网下载了文档研究了下:官网地址:http://www.zhuozhengsoft.com/

不多说,直接写上学习过程,请大家指正。练习过程整合了Struts进行练习,其他框架可以结合具体业务添加:


在使用之前有几点要注意:

1、在本机上安装posetup.exe,如果用到印章还要安装sealsetup.exe.

2、这个在最新版本的chrome中不能直接打开,通过link方式才行,没弄过,可以看一下。刚开始我就遇到这种问题,IE、firefox可以,还有就是版本问题

3、系统会自动检测本机上有的office软件,自动检测第一次安装的office软件(避免同时有WPS和MSOffice)。

4、pageOffice是收费的,可以试用,为避免在页面中总是输入注册,可离线生成license.lic,copy到lib下,方便开发。

5、。。。。。。。

环境:eclipse3.7+jdk6+tomcat7

第一步:新建一个web工程:

工程目录如下:


注:doc 目录下问为文档模板或pdf文件等,可自动生成带有印章的公司文档(如请假条,在线填写姓名、事由等,生成文档,再由领导同意,生成一份完整请假条)。

第二步:在web.xml中添加官网给出的配置:



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>pageOfficeDemo</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  
  <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>
  		org.apache.struts2.dispatcher.FilterDispatcher
  	</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
  </filter-mapping>
  <filter-mapping>
	<filter-name>struts2</filter-name>
	<url-pattern>*.jsp</url-pattern>
  </filter-mapping>

  
  <!-- 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>/poserver.do</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
	<servlet-name>poserver</servlet-name> 
	<url-pattern>/pageoffice.cab</url-pattern>
  </servlet-mapping>
  <servlet-mapping> 
	<servlet-name>poserver</servlet-name> 
	<url-pattern>/popdf.cab</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>
    <servlet-name>adminseal</servlet-name> 
    <servlet-class>com.zhuozhengsoft.pageoffice.poserver.AdminSeal</servlet-class> 
  </servlet>
  <servlet-mapping> 
    <servlet-name>adminseal</servlet-name> 
    <url-pattern>/adminseal.do</url-pattern> 
  </servlet-mapping>
  <servlet-mapping> 
    <servlet-name>adminseal</servlet-name> 
    <url-pattern>/loginseal.do</url-pattern>
  </servlet-mapping>
  <servlet-mapping> 
    <servlet-name>adminseal</servlet-name> 
    <url-pattern>/sealimage.do</url-pattern>
  </servlet-mapping>
  <mime-mapping>  
  	<extension>mht</extension>  
  	<mime-type>message/rfc822</mime-type>  
  </mime-mapping>
  <context-param>
  	<param-name>adminseal-password</param-name>
  	<param-value>111111</param-value>
  </context-param>
  
  
  <!-- 连接数据库信息配置-->
  <context-param>
		<param-name>adminseal-charset</param-name>
		<param-value>UTF-8</param-value>
	</context-param>
  
 <context-param>
  	<param-name>posealdb-driver</param-name>
  	<param-value>com.mysql.jdbc.Driver</param-value>
  </context-param>
  <context-param>
  	<param-name>posealdb-url</param-name>
  	<param-value>jdbc:mysql://localhost:3306/pageoffice</param-value>
  </context-param>
  <context-param>
  	<param-name>posealdb-username</param-name>
  	<param-value>root</param-value>
  </context-param>
  <context-param>
  	<param-name>posealdb-password</param-name>
  	<param-value>root</param-value>
  </context-param>
  
  <!-- PageOffice End -->
</web-app>

第三步:进行代码编写

 Struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
	
	<package name="demo" extends="struts-default">
	
		<action name="createWord" class="com.demo.action.WordDemo" method="create">
			<result name="create">/createWord.jsp</result>
		</action>
		<action name="autoInsert" class="com.demo.action.WordDemo" method="autoInsert">
			<result name="autoInsert">/autoInsert.jsp</result>
		</action>
	
		<action name="openword" class="com.demo.action.WordDemo" method="openword">
			<result name="openword">/editword.jsp</result>
		</action>
		<action name="openPDF" class="com.demo.action.WordDemo" method="openPDF">
			<result name="pdf">/openPDF.jsp</result>
		</action>
		
		<action name="wordToPDF" class="com.demo.action.WordDemo" method="wordToPDF">
			<result name="wordToPDF">/wordToPDF.jsp</result>
		</action>
		
		<action name="saveword" class="com.demo.action.WordDemo" method="saveword">
			<result name="saveword">/savefile.jsp</result>
		</action>
		<action name="openexcel" class="com.demo.action.ExcelDemo" method="openexcel">
			<result name="openexcel">/editexcel.jsp</result>
		</action>
		
		<action name="saveexcel" class="com.demo.action.ExcelDemo" method="saveexcel">
			<result name="saveexcel">/savefile.jsp</result>
		</action>
	</package>

</struts>    

操作word和excel的action(其他的可参看手册练习):

WordDemo:


package com.demo.action;

import java.awt.Color;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;
import com.zhuozhengsoft.pageoffice.BorderStyleType;
import com.zhuozhengsoft.pageoffice.DocumentOpenType;
import com.zhuozhengsoft.pageoffice.DocumentVersion;
import com.zhuozhengsoft.pageoffice.FileMakerCtrl;
import com.zhuozhengsoft.pageoffice.FileSaver;
import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PDFCtrl;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice.ThemeType;
import com.zhuozhengsoft.pageoffice.wordwriter.WordDocument;

public class WordDemo extends ActionSupport implements ServletRequestAware,
		ServletResponseAware {

	private static final long serialVersionUID = -758686623642845302L;
	private HttpServletRequest request;
	private HttpServletResponse response;
	private String message = "";
	
	private String title;
	

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		System.out.println(title);
		this.title = title;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	public String getMessage() {
		return message;
	}

	public String create() throws Exception {
		PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(
				ServletActionContext.getRequest());
		System.out.println("create执行到此---------》" + poCtrl1);
		poCtrl1.setServerPage(request.getContextPath() + "/poserver.zz"); // 此行必须

		// 隐藏菜单栏
		poCtrl1.setMenubar(true);
		// 设置Office办公软件类型
		// poCtrl1.setOfficeVendor(OfficeVendorType.WPSOffice);

		poCtrl1.addCustomToolButton("保存", "SaveDocument()", 1);
		// 隐藏工具栏
		poCtrl1.setCustomToolbar(true);
		// 设置边框颜色
		poCtrl1.setBorderColor(Color.blue);
		// 设置边框样式
		poCtrl1.setBorderStyle(BorderStyleType.BorderThin);
		// 设置标题栏文字
		poCtrl1.setCaption("创建一个文档");

		// 保存前的检查
		// poCtrl1.setJsFunction_BeforeDocumentSaved("BeforeDocumentSaved()");

		// 设置保存页面
		poCtrl1.setSaveFilePage("saveword.action");

		// 新建Word文件,webCreateNew方法中的两个参数分别指代“操作人”和“新建Word文档的版本号”
		poCtrl1.webCreateNew("vivid", DocumentVersion.Word2007);
		poCtrl1.setTagId("PageOfficeCtrl1"); // 此行必须

		return "create";
	}

	/**
	 * 在线打开一个PDF
	 */
	public String openPDF() throws Exception {
		PDFCtrl pdf = new PDFCtrl(ServletActionContext.getRequest());
		pdf.setServerPage(request.getContextPath() + "/poserver.zz");
		System.out.println(request.getContextPath());
		// 设置界面样式
		pdf.setBorderColor(Color.RED);
		pdf.setCaption("创建一个PDF");
		pdf.setBorderStyle(BorderStyleType.BorderFlat);
		pdf.setTheme(ThemeType.Office2010);
		//设置菜单选项
		pdf.addCustomToolButton("打印", "Print()", 6);
		pdf.addCustomToolButton("隐藏/显示书签", "SetBookmarks()", 0);
		pdf.addCustomToolButton("-", "", 0);
		//搜索设置
		pdf.addCustomToolButton("搜索", "SearchText()", 0);
		pdf.addCustomToolButton("搜索下一个", "SearchTextNext()", 0);
		pdf.addCustomToolButton("搜索上一个", "SearchTextPrev()", 0);
		pdf.addCustomToolButton("实际大小", "SetPageReal()", 16);
		pdf.addCustomToolButton("适合页面", "SetPageFit()", 17);
		pdf.addCustomToolButton("适合宽度", "SetPageWidth()", 18);
		pdf.addCustomToolButton("-", "", 0);
		pdf.addCustomToolButton("首页", "FirstPage()", 8);
		pdf.addCustomToolButton("上一页", "PreviousPage()", 9);
		pdf.addCustomToolButton("下一页", "NextPage()", 10);
		pdf.addCustomToolButton("尾页", "LastPage()", 11);
		pdf.addCustomToolButton("-", "", 0);
		// // 关闭菜单
		// pdf.setMenubar(false);
		// 打开PDF文档
		pdf.webOpen("doc/test.pdf");
		pdf.setTagId("PDFCtrl1");

		return "pdf";
	}
/**
 * 将文档转为pdf
 */
	public String wordToPDF() throws Exception{
		
		FileMakerCtrl fmCtrl = new FileMakerCtrl(request);
		fmCtrl.setServerPage(request.getContextPath()+"/poserver.zz");
		WordDocument doc = new WordDocument();
		//禁用右击事件
		doc.setDisableWindowRightClick(true);
		//给数据区域赋值,即把数据填充到模板中相应的位置
		doc.openDataRegion("PO_company").setValue("北京卓正志远软件有限公司  ");
		fmCtrl.setSaveFilePage("saveword.action");
		fmCtrl.setWriter(doc);
		fmCtrl.setJsFunction_OnProgressComplete("OnProgressComplete()");
		fmCtrl.fillDocumentAsPDF("doc/template.doc", DocumentOpenType.Word, "a.pdf");
		fmCtrl.setTagId("FileMakerCtrl1"); //此行必须

		return "wordToPDF";
	}
	/**
	 * 
	 * @Title: autoInsert
	 * @Description: 自动添加到文档中
	 * @author vivid
	 * @time 2016-3-24 下午4:38:38
	 * @return
	 * @throws Exception
	 */
	public String autoInsert() throws Exception {
		// 1、初始化实例
		FileMakerCtrl fmCtrl = new FileMakerCtrl(
				ServletActionContext.getRequest());
		fmCtrl.setServerPage(request.getContextPath() + "/poserver.zz");
		System.out.println(request.getContextPath());
		// 生成随机id
		String id = String.valueOf(new Random().nextInt(100));
		System.out.println(id);
		// String id = "2";
		request.setAttribute("id", id);
		System.out.println(title);
		if (id != null && id.length() > 0) {
			// WordDocument 类代表一个Word文档,用来读取用户输入到Word文档中的数据
			WordDocument doc = new WordDocument();
			// 禁用右击事件
			doc.setDisableWindowRightClick(true);
			// 给数据区域赋值,即把数据填充到模板中相应的位置
			doc.openDataRegion("PO_company").setValue(title);
		//	doc.openDataRegion("po_second").setValue("mftcc" + id);
			// 设置 saveMaker.jsp 用来保存文档。
			fmCtrl.setSaveFilePage("saveMaker.jsp?id=" + id);
			fmCtrl.setWriter(doc);
			fmCtrl.setJsFunction_OnProgressComplete("OnProgressComplete()");
			fmCtrl.setFileTitle("文档" + id + ".doc");
			fmCtrl.fillDocument("doc/template.doc", DocumentOpenType.Word);
		}
		fmCtrl.setTagId("FileMakerCtrl1"); // 此行必须

		return "autoInsert";
	}

	/*
	 * 打开文档并修改保存
	 */
	public String openword() throws Exception {
		PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(
				ServletActionContext.getRequest());
		poCtrl1.setServerPage("poserver.zz"); // 此行必须
		// 设置标题
		poCtrl1.setCaption("打开文档操作");
		// 创建工具条
		poCtrl1.addCustomToolButton("保存", "SaveDocument()", 1);
		poCtrl1.addCustomToolButton("-", "", 0);
		poCtrl1.addCustomToolButton("打印", "ShowPrintDlg()", 6);
		poCtrl1.addCustomToolButton("-", "", 0);
		poCtrl1.addCustomToolButton("全屏切换", "SetFullScreen()", 4);
		poCtrl1.addCustomToolButton("-", "", 0);
		poCtrl1.addCustomToolButton("加盖印章", "AddSeal()", 5);
		poCtrl1.addCustomToolButton("手写签批", "AddHandSign()", 5);
		poCtrl1.addCustomToolButton("验证印章", "VerifySeal()", 5);
		poCtrl1.setSaveFilePage("saveword.action");
		poCtrl1.webOpen("doc/test.doc", OpenModeType.docNormalEdit, "张三");
		poCtrl1.setTagId("PageOfficeCtrl1"); // 此行必须
		return "openword";
	}

	/*
	 * 文档保存操作
	 */
	public String saveword() throws Exception {
		FileSaver fs = new FileSaver(request, response);
		request.setAttribute("FileSaver", fs);
		fs.saveToFile(request.getSession().getServletContext()
				.getRealPath("doc/")
				+ "/" + fs.getFileName());
		// fs.saveToFile(request.getContextPath()+"/doc/"+fs.getFileName());
		System.out.println(request.getSession().getServletContext()
				.getRealPath("doc/"));
		System.out.println(fs.getFileName());
		fs.showPage(200, 400);
		message = "保存成功!";
		return "saveword";
	}

}
ExcelDemo:


package com.demo.action;

import java.awt.Color;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;
import com.zhuozhengsoft.pageoffice.BorderStyleType;
import com.zhuozhengsoft.pageoffice.FileSaver;
import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice.excelwriter.Cell;
import com.zhuozhengsoft.pageoffice.excelwriter.Sheet;
import com.zhuozhengsoft.pageoffice.excelwriter.Workbook;

/**
 * 
 * @ClassName: ExcelDemo
 * @Description: TODO
 * @author vivid
 * @date 2016-3-24 下午1:22:55
 * 
 */
@SuppressWarnings("serial")
public class ExcelDemo extends ActionSupport implements ServletRequestAware,
		ServletResponseAware {

	private HttpServletRequest request;
	private HttpServletResponse response;
	private String message = "";

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	public String getMessage() {
		return message;
	}

	// 此处只简单的实现了Excel文件的在线编辑和保存,
	// 动态填充单元格、提交单元格等其他功能的实现请参考通过JSP编写的示例
	public String openexcel() throws Exception {
		PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(
				ServletActionContext.getRequest());
		poCtrl1.setServerPage("poserver.do"); // 此行必须

		poCtrl1.setCaption("操作Excel文档");
		//设置边框的类型
		poCtrl1.setBorderStyle(BorderStyleType.BorderThin);
		//设置边框的颜色
		poCtrl1.setBorderColor(Color.blue);
		
		// 代表一个Excel文档,用来读取用户输入到Excel表格中的数据,填充Excel表格
		Workbook workbook = new Workbook();
		// 参数为要打开的Excel文件中的Sheet表单的名称
		Sheet sheet = workbook.openSheet("Sheet1");
		// 获取sheet名称
		String name = sheet.getName();
		System.out.println("--------" + name);
		// 打开指定的单元格(“B4”单元格),并返回 Cell 对象
		Cell B4 = sheet.openCell("B4");
		// 给单元格赋值
		B4.setValue("B产品");
		// 设置单元格前景色
		B4.setForeColor(Color.green);
		
		
		// 打开指定的表格,并返回 Table 对象
		// Table XXX =sheet.openTable("XXX");
		

		// 提交单元格数据
		// B4.setSubmitName("pname");

		poCtrl1.setWriter(workbook);
		// 工具栏
		poCtrl1.addCustomToolButton("保存", "SaveDocument()", 1);
		poCtrl1.addCustomToolButton("-", "", 0);
		poCtrl1.addCustomToolButton("打印", "ShowPrintDlg()", 6);
		poCtrl1.addCustomToolButton("-", "", 0);
		poCtrl1.addCustomToolButton("全屏切换", "SetFullScreen()", 4);
		poCtrl1.addCustomToolButton("-", "", 0);
		poCtrl1.addCustomToolButton("加盖印章", "AddSeal()", 5);
		poCtrl1.addCustomToolButton("手写签批", "AddHandSign()", 5);
		poCtrl1.addCustomToolButton("验证印章", "VerifySeal()", 5);
		// 设置保存页
		poCtrl1.setSaveFilePage("saveexcel.action");
		// 打开文件
		poCtrl1.webOpen("doc/test.xls", OpenModeType.xlsNormalEdit, "张三");
		poCtrl1.setTagId("PageOfficeCtrl1"); // 此行必须
		return "openexcel";
	}

	public String saveexcel() throws Exception {
		FileSaver fs = new FileSaver(request, response);
		request.setAttribute("FileSaver", fs);
		// 将修改的Excel文件保存到相应的路径下
		fs.saveToFile(request.getSession().getServletContext()
				.getRealPath("doc/")
				+ "/" + fs.getFileName());
		// 弹出窗口显示保存结果
		// fs.showPage(300, 300);
		// message = "显示自定义保存结果。";
		// 设置保存结果信息
		fs.setCustomSaveResult("success");
		return "saveexcel";
	}

}

下面以在线生成word示例作为记录,其他自己练习,或下载我的代码查看:http://download.csdn.net/detail/erris/9474348


首页index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
    <title>pageOfficeDemo</title>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  <script type="text/javascript">
 
  
  </script>
  
  <body>
  <div style="text-align:center;">
      <b>PageOfficeDemo</b><br>
      <br>
    <a href="createWord.action" style="font:blue">1、在线创建一个word文档</font></a><br/><br/>
    <a href="openword.action " style="font:blue"> 2、在线编辑保存Word文档</font></a> <br/><br/>
    <a href="href.jsp" style="font:blue">3、在线替换word文档内容</font></a> <br/><br/>
    <a href="openexcel.action"  style="font:blue">4、在线编辑保存Excel文档</font></a> <br/><br/>
       <a href="openPDF.action" style="font:blue">5、在线打开PDF文档</font></a> <br/><br/>
       <a href="wordToPDF.action" style="font:blue">6、word插入数据后保存为PDF</font></a> <br/><br/>
  </div>

  </body>
</html>

生成word文档:


<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.pageoffice.cn" prefix="po"%> <!-- 必须 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>
<body>
	<!--**************   卓正 PageOffice 客户端代码开始    ************************-->
	<script language="javascript" type="text/javascript">
		function SaveDocument() {
			var title = document.getElementById("title").value;
				alert(title);
			if (title != null) {

				document.getElementById("PageOfficeCtrl1").WebSave();
			} else {
				alert("请输入要保存的文件名!!");
			}
			//alert(document.getElementById("PageOfficeCtrl1").CustomSaveResult);
		}
	</script>
	
	<div style="width: 100%; height: 800px">
		<po:PageOfficeCtrl id="PageOfficeCtrl1" />
	</div>
</body>
</html>

运行截图:


源码下载地址:http://download.csdn.net/detail/erris/9474348

2016-08-21 13:13:00 chuandanmi5788 阅读数 20

jsaas-cloud-community

 

  1. 运行环境要求:

     

  2. Windows 2003+,Linux 7+
  3. JDK1.6+
  4. MySql 5.5+
  5. Tomcat 6+
  6. Eclipse

1. JSAAS简介

 

JSAAS企业应用平台是一款带有企业信息化基础管理的Saas开发平台框架,它是基于流行的轻量级框架Spring上构建,以支持中小企业、大型集团企业、政府单位的日常事务管理,平台提供基础的数据交互功能模块、文档处理管理模块、组织架构管理模块、流程管理模块、企业公告、微信交互管理模块等,适合于有IT研发能力的大型企业或向Saas应用运维的IT开发企业。同时整合了Activiti流程,并且进行扩展以支持国内流程的需求,可以有效满足企业或部门的OA办公或BPM业务需求。

 

其平台架构如下所示:

平台的使用价值:

平台的流程业务支持:

 

2. 整合开源技术

 

    1. JAVA 1.6 +
      • Spring Core核心容器
      • Spring  MVC 4
      • Spring AOP
      • Spring Security
      • Groovy动态脚本语言
      • MiniUI前端JS框架
      • Jquery javascrip库
      • MyBatis Or JDBC数据持久层框架
      • Maven版本控制
      • Log4j Java XML API
      • Scheduling Quartz定时任务
      • Alfresco Activiti 5
      • JQuery
      • Ueditor
      • Code Mirror
      • PageOffice
      • Google Calender
      • Jquery Ystep
      • 其他控件等

 

 

3. 传统应用开发支持

 

 

JSAAS是一款可以开发政府办公应用、业务流程系统、企业OA、企业的业务管理系统等、它基于以下开源框架上构建,因此,对于JAVA的开发人员来说,这是一款容易上手的

开发框架,特别是流程业务的支持,所以在开发传统的业务系统时,它会更加节省你的开发成本,结合外围开放的接口,可以有效支持多种端的接入,如手机端、微信端等。

虽然市面上有比较多的以下系统,但很多业务未必适合一些企业使用,定制开发自身的业务更加适合企业。

 

CRM(客户关系管理)

OA (协同管理)

ERP(企业应用管理)

KMS(知识管理)

HRM(人力资源管理)

DRP(分销应用管理)

 

4. 云应用或租户应用的支持

 

目前云应用是非常火的,JSAAS通过对组织架构及业务数据的逻辑划分,可以支持小规模的云端应用,而对于大模规的数据的云端应用,平台通过扩展应用服务器及数据库实例,以可以支持更大更快更安全的数据访问。

saas-deploy

 

在云端应用上,我们可以构建以下应用:
JSAAS_680

如我们基于JSAAS上可以开发企业的协同平台,其访问例子如下:

 

http://www.redxun.cn:8020/saweb/index.do

 

系统界面如下所示:
flow
jsaas-ent

5. JSAAS社区开源版

目前红迅软件推出开源社区版,并且提供开发学习讲解视频。满足开发人员对平台设计思想的理解、同时可以基于上面开发自身的业务应用。我们同时为同行企业或有开发能力的企业提供全开源的企业版,推进与合作伙伴深入合作,构建企业私有云与公有云应用。

      • 开源版源代码下载

https://pan.baidu.com/s/1pLKp9V1

获取密码请发邮件至3102760881@qq.com

      • 学习视频
      • 部分在线文档讲解

http://www.redxun.cn/?cat=49

      • Wiki文档


1.如何实现Activiti的分支条件的自定义配置
2.Activiti的自定义组织架构及在流程中的应用
3.Activiti如何实现流程的回退
4.JSAAS如何让外部业务功能参与Activiti流程的审批
5.JSAAS的Activiti会签开发扩展处理
6.Activiti的全局事件机制及其监听处理
在线试用地址:http://www.redxun.cn:8020/saweb/login.jsp

转载于:https://my.oschina.net/man1900/blog/735732

2017-10-31 17:44:07 qq_33583322 阅读数 4736

我做的功能还是蛮简单的,就是使用浏览器打开一个pdf文档,不废话,上步骤:

1.安装相关软件

http://www.zhuozhengsoft.com/download.html 下载sealsetup.exe、pageoffice.jar和posetup.exe,jar包的话如果大家使用maven可以百度下maven导入本地jar包方法,拷贝posetup.exe到项目的WEB-INF\lib目录下 ,我这里因为只做pdf展示,所以只用posetup.exe,那个license.lic是注册码文件,度娘提供方法大家自己查下。
这里写图片描述

2.配置web.xml,直接在web.xml添加如下代码:

<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>/poserver.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>poserver</servlet-name>
<url-pattern>/pageoffice.cab</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>poserver</servlet-name>
<url-pattern>/popdf.cab</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>
<servlet-name>adminseal</servlet-name>
<servlet-class>com.zhuozhengsoft.pageoffice.poserver.AdminSeal</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>adminseal</servlet-name>
<url-pattern>/adminseal.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>adminseal</servlet-name>
<url-pattern>/loginseal.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>adminseal</servlet-name>
<url-pattern>/sealimage.do</url-pattern>
</servlet-mapping>
<mime-mapping>
  <extension>mht</extension>
  <mime-type>message/rfc822</mime-type>
 </mime-mapping>
 <context-param>
  <param-name>adminseal-password</param-name>
  <param-value>111111</param-value>
 </context-param>

3.我说配置完成你可能不信,下面开始写代码( pdf查看)

3.1先写一个链接指向我们显示pdf的jsp页面

<a href="<%=PageOfficeLink.openWindow(request,"/pdf","width=auto;height=auto;")%>">查看</a>

我这里用的是spring里的那一套东西 “/pdf” 是后台的一个get方法,代码如下:

@Controller
public class PdfController {
    //查看pdf
    @RequestMapping(value = "pdf",method = RequestMethod.GET)
    public String getPdf() {

        return "deploy/PDF";
    }
}

3.2 PDFjsp显示页面代码,只需要改一下要显示的pdf文件路径,我这里放在了static静态资源里

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import="com.zhuozhengsoft.pageoffice.*, com.zhuozhengsoft.pageoffice.wordwriter.*,java.awt.*"%>
<%@ taglib uri="http://java.pageoffice.cn" prefix="po" %>
<%

    PDFCtrl poCtrl1 = new PDFCtrl(request);
    poCtrl1.setServerPage(request.getContextPath()+"/poserver.zz"); //此行必须

// Create custom toolbar
    poCtrl1.addCustomToolButton("打印", "Print()", 6);
    poCtrl1.addCustomToolButton("隐藏/显示书签", "SetBookmarks()", 0);
    poCtrl1.addCustomToolButton("-", "", 0);
    poCtrl1.addCustomToolButton("实际大小", "SetPageReal()", 16);
    poCtrl1.addCustomToolButton("适合页面", "SetPageFit()", 17);
    poCtrl1.addCustomToolButton("适合宽度", "SetPageWidth()", 18);
    poCtrl1.addCustomToolButton("-", "", 0);
    poCtrl1.addCustomToolButton("首页", "FirstPage()", 8);
    poCtrl1.addCustomToolButton("上一页", "PreviousPage()", 9);
    poCtrl1.addCustomToolButton("下一页", "NextPage()", 10);
    poCtrl1.addCustomToolButton("尾页", "LastPage()", 11)**重点内容**;
    poCtrl1.addCustomToolButton("-", "", 0);

    poCtrl1.webOpen("statics/PDF/userhelp.pdf");//**这里改成自己的路径**
    poCtrl1.setTagId("PDFCtrl1"); //此行必须
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>在线打开PDF文件</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
</head>

<body>
<!--**************   卓正 PageOffice 客户端代码开始    ************************-->
<script language="javascript" type="text/javascript">
    function AfterDocumentOpened() {
        //alert(document.getElementById("PDFCtrl1").Caption);
    }
    function SetBookmarks() {
        document.getElementById("PDFCtrl1").BookmarksVisible = !document.getElementById("PDFCtrl1").BookmarksVisible;
    }

    function Print() {
        document.getElementById("PDFCtrl1").ShowDialog(4);
    }
    function SwitchFullScreen() {
        document.getElementById("PDFCtrl1").FullScreen = !document.getElementById("PDFCtrl1").FullScreen;
    }
    function SetPageReal() {
        document.getElementById("PDFCtrl1").SetPageFit(1);
    }
    function SetPageFit() {
        document.getElementById("PDFCtrl1").SetPageFit(2);
    }
    function SetPageWidth() {
        document.getElementById("PDFCtrl1").SetPageFit(3);
    }
    function ZoomIn() {
        document.getElementById("PDFCtrl1").ZoomIn();
    }
    function ZoomOut() {
        document.getElementById("PDFCtrl1").ZoomOut();
    }
    function FirstPage() {
        document.getElementById("PDFCtrl1").GoToFirstPage();
    }
    function PreviousPage() {
        document.getElementById("PDFCtrl1").GoToPreviousPage();
    }
    function NextPage() {
        document.getElementById("PDFCtrl1").GoToNextPage();
    }
    function LastPage() {
        document.getElementById("PDFCtrl1").GoToLastPage();
    }
    function RotateRight() {
        document.getElementById("PDFCtrl1").RotateRight();
    }
    function RotateLeft() {
        document.getElementById("PDFCtrl1").RotateLeft();
    }
</script>
<!--**************   卓正 PageOffice 客户端代码结束    ************************-->
<div style="width:auto; height:600px;">
    <po:PDFCtrl id="PDFCtrl1" />
</div>
</body>
</html>

到这里就结束了,下面是效果图,欢迎大家一起交流经验。
这里写图片描述

书签备份

阅读数 6914