`
jxqc_job
  • 浏览: 529 次
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
我的工作流demo-7_sql语句
insert into tb_process_picture(nodeName, nodeLocation_x, nodeLocation_y, nodeLocation_w, nodeLocation_h) 
values('开始',74,156,48,48);
insert into tb_process_picture(nodeName, nodeLocation_x, nodeLocation_y, nodeLocation_w, nodeLocation_h) 
values('主管审批',197,158,92,52);
insert into tb_process_picture(nodeName, nodeLocation_x, nodeLocation_y, nodeLocation_w, nodeLocation_h) 
values('经理审批',517,157,92,52);
insert into tb_process_picture(nodeName, nodeLocation_x, nodeLocation_y, nodeLocation_w, nodeLocation_h) 
values('老板审批',522,289,92,52);
insert into tb_process_picture(nodeName, nodeLocation_x, nodeLocation_y, nodeLocation_w, nodeLocation_h) 
values('结束',747,157,48,48);
commit;
我的工作流demo-6
30.qingjia.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>
	<form action="user/deployFlow!apply" method="post">
		<table>
			<tr>
				<th colspan="2">请假申请</th>
			</tr>
			<tr>
				<td>请假人:</td>
				<td><input type="text" name="askForLeave.aflName" /></td>
			</tr>
			<tr>
				<td>请假天数:</td>
				<td><input type="text" name="askForLeave.aflDays" /></td>
			</tr>
			<tr>
				<td>请假事由:</td>
				<td><input type="text" name="askForLeave.aflDesc" /></td>
			</tr>
			<tr>
				<td><input type="submit" value="提交" /></td>
			</tr>
		</table>
	</form>
</body>
</html>

31.queryDeployment.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>查看已部署的流程</title>
</head>
<body>
	<table width="30%">
	<c:forEach var="deployProcess" items="${deployProcesses}">
		<tr>
			<td>${deployProcess.id}</td>
			<td>${deployProcess.name}</td>
			<td>${deployProcess.version}</td>
			<td><a href="">流程删除</a></td>
			<td><a href="deployFlow!showPictureNode?id=${deployProcess.id}">查看流程图</a></td>
		</tr>
	</c:forEach> 
	</table>
</body>
</html>

32.success.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>success</title>
</head>
<body>
	success!!!
</body>
</html>

33.view.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ 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>show</title>
<%
	String id = request.getParameter("id");
%>
</head>
<body>
<img src="user/deployFlow!showImg?id=<%=id%>" style="position:absolute;left:0px;top:0px;">
<div style="position:absolute;border:1px solid red;left:<s:property value="#request.X"/>px;top:<s:property value="#request.Y"/>px;width:<s:property value="#request.width"/>px;height:<s:property value="#request.height"/>px;"></div>
</body>
</html>

34.waitingTask.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>待办任务</title>
</head>
<body>
	<table border="1" width="40%">
		<tr>
			<th>id</th>
			<th>请假人</th>
			<th>请假天数</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
		<c:forEach var="askForLeave" items="${taskList}">
			<tr>
				<td><a href="deployFlow!query?act=${askForLeave.currentNodeNum}&id=${askForLeave.id}">${askForLeave.id}</a></td>
				<td>${askForLeave.aflName}</td>
				<td>${askForLeave.aflDays}</td>
				<td>${askForLeave.auditStatus}</td>
				<td><a href="deployFlow!showPictureNode?id=${askForLeave.currentNodeNum}">查看流程图</a></td>
			</tr>
		</c:forEach> 
	</table>
</body>
</html>
我的工作流demo-5
22.log4j.properties
#log4j.rootCategory=INFO,stdout,file  
#配置根Logger  
log4j.rootLogger=INFO,file,CONSOLE   
log4j.additivity.org.apache=true  
  
#日志信息输出到控制台 
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender   
log4j.appender.CONSOLE.Threshold=INFO   
log4j.appender.CONSOLE.Target=System.out   
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout   
log4j.appender.CONSOLE.layout.ConversionPattern=%d %l-%m%n 

#输出到指定的日志文件
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender  
#日志文件的输出路径  
log4j.appender.file.File=d\:/hplog/mylogs.log    
log4j.appender.FILE.MaxFileSize=10MB 
log4j.appender.file.layout=org.apache.log4j.PatternLayout
#输出INFO级别以上的日志  
log4j.appender.file.Threshold = INFO   
log4j.appender.file.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %l-%m%n   

23.proxool.xml
<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
	<proxool>
		<!--连接池的别名 -->
		<alias>hp</alias>
		<!--proxool只能管理由自己产生的连接 -->
		<driver-url>jdbc:mysql://10.23.28.231:3306/db_ssh2jbpm</driver-url>
        <!-- JDBC驱动程序-->
		<driver-class>com.mysql.jdbc.Driver</driver-class>
		<driver-properties>
			<property name="user" value="root" />
			<property name="password" value="Td123456" />
		</driver-properties>
		
		<!-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回 收,超时的销毁 -->
		<house-keeping-sleep-time>90000</house-keeping-sleep-time>
		<!-- 指因未有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的 用户连接就不会被接受 -->
		<simultaneous-build-throttle>20</simultaneous-build-throttle>
		<!-- 最少保持的空闲连接数 -->
		<prototype-count>5</prototype-count>
		<!-- 允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的 等待请求数由maximum-new-connections决定 -->
		<maximum-connection-count>100</maximum-connection-count>
		<!-- 最小连接数 -->
		<minimum-connection-count>10</minimum-connection-count>
		<!-- add time: 2013-5-14 begin -->
		<test-before-use>true</test-before-use>
		<test-after-use>true</test-after-use>
		<house-keeping-test-sql>SELECT CURRENT_USER</house-keeping-test-sql>
		<!-- add time: 2013-5-14 end -->
	</proxool>
</something-else-entirely>

24.struts.properties
struts.multipart.maxSize=314572800

25.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>
    <!-- 将struts2的Action交给Spring管理 -->
    <constant name="struts.objectFactory" value="spring" />
	<!-- 配置其他常量 -->
	<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
	<constant name="struts.i18n.encoding" value="UTF-8" />
	<constant name="struts.enable.DynamicMethodInvocation" value="true" />
	
	<!-- 用户模块的Action配置 -->
	<package name="struts_user" extends="struts-default" namespace="/user">
		<action name="user" class="userAction">
			<result name="success" type="redirect">/index.jsp</result>
			<!-- <result name="input">/login.jsp</result> -->
		</action>
		<action name="deployFlow" class="deployFlowAction">
			<result name="success">/queryDeployment.jsp</result>
			<result name="queryDeployment">/queryDeployment.jsp</result>
			<result name="showPic">/view.jsp</result>
			<result name="waitingTask">/waitingTask.jsp</result>
			<result name="audit">/audit.jsp</result>
		</action>
		<action name="req" class="deployFlowAction" method="taskStart"></action>
	</package>
	
</struts>

26.addUser.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>
	<h3>添加用户</h3>
	<form action="user/user!addUser" method="post">
		姓名: <input type="text" id="name" name="user.name"/><br /><br />
		年龄: <input type="text" id="age" name="user.age"/><br /><br />
		<input type="submit" value="添加"/>
	</form>
</body>
</html>

27.audit.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>
	<form action="user/deployFlow!audit" method="post">
		<table>
			<tr>
				<th colspan="2">${title}</th>
			</tr>
			<tr>
				<td>请假人:</td>
				<td>${askForLeave.aflName}</td>
			</tr>
			<tr>
				<td>请假天数:</td>
				<td>${askForLeave.aflDays}</td>
			</tr>
			<tr>
				<td>审批结果:</td>
				<td>
					<select name="auditResult">
						<option value="true">批准</option>
						<option value="false">不批准</option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" value="提交" /></td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="hidden" name="askForLeave.id" value="${askForLeave.id}" />
					<input type="hidden" name="askForLeave.aflDays" value="${askForLeave.aflDays}" />
					<input type="hidden" name="askForLeave.currentNodeNum" value="${askForLeave.currentNodeNum}" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

28.error.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>error</title>
</head>
<body>
	error!!!
</body>
</html>

29.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>welcome</title>
<style type="text/css">
	#top{
		width:99%;
		height:50px;
		float:top;
		border-color:blue;
		border:1px solid;
	}
	#main{
		width:100%;
		height:84%;
		float:top;
		position:absolute;
	}
	#leftFrame{
		width:10%;
		height:100%;
		border:1px solid;
		float:left;
	}
	#rightFrame{
		width:88%;
		height:100%;
		border:1px solid;
		float:left;
	} 
	#treeDiv{
		margin-left:10%;
		background-color:white;
	}
	div{
		font-size:14px;
	}
	#bg_frame{
		background-color:lightblue;
	}
</style>
</head>
<body>
	<div id="top">事务管理系统</div>
	<div id="main">
		<div id="leftFrame">
			<div>
				<div id="bg_frame">日常审批</div>
				<div id="treeDiv"><a href="user/deployFlow!waitingTask">待办任务</a></div>
				<div id="treeDiv"><a href="user/deployFlow!historyTask">已办任务</a></div>
			</div>
			<div>
				<div id="bg_frame">日常任务</div>
				<div id="treeDiv"><a href="qingjia.jsp">请假</a></div>
			</div>
		</div>
		<div id="rightFrame">
			
		</div> 
	</div>
</body>
</html>
我的工作流demo-4
15.qj.jpdl.xml
<?xml version="1.0" encoding="UTF-8"?>

<process name="qj" id="qj" xmlns="http://jbpm.org/4.4/jpdl">
   <start name="start1" g="74,156,48,48">
      <transition name="to 主管审批" to="主管审批" g="-35,-26"/>
   </start>
   <end name="end1" g="747,157,48,48"/>
   <decision name="exclusive1" g="395,160,48,48">
      <transition name="to 经理审批" to="经理审批" g="-32,-28">
      	<condition expr="#{tra='to_manager'}"></condition>
      </transition>
      <transition name="to 老板审批" to="老板审批" g="422,316:-69,-22">
      	<condition expr="#{tra='to_boss'}"></condition>
      </transition>
      <transition name="to end1" to="end1" g="419,59:-56,22"/>
   </decision>
   <task name="主管审批" g="197,158,92,52">
      <transition name="to exclusive1" to="exclusive1" g="-33,-25"/>
   </task>
   <task name="经理审批" g="517,157,92,52">
      <transition name="to end1" to="end1" g="-50,-22"/>
   </task>
   <task name="老板审批" g="522,289,92,52">
      <transition name="to end1" to="end1" g="-50,-22"/>
   </task>
</process>

16.applicationContext_action.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!--Action bean -->
	<!-- 给action添加scope属性用来避免spring创建单例,这样防止线程不安全 -->
	<!-- <bean id="dQDocumentAction" class="com.tdtech.pdm.create.action.DQDocumentAction" scope="prototype">
		<property name="dQDocumentServiceImpl" ref="dQDocumentServiceImpl"></property>
	</bean>  -->
	<bean id="deployFlowAction" class="com.hp.action.DeployFlowAction" scope="prototype">
		<property name="userService" ref="userService"></property>
	</bean>
	<bean id="userAction" class="com.dan.action.UserAction">
		<property name="userService" ref="userService"></property>
	</bean>
</beans>

17.applicationContext_dao.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!-- 配置HibernateTemplate bean -->
	<!-- <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean> -->
	<!-- 配置Dao层bean -->
	<!-- <bean id="dQDocumentDaoImpl" class="com.tdtech.pdm.create.dao.impl.DQDocumentDaoImpl">
		<property name="hibernateTemplate" ref="hibernateTemplate"></property>
	</bean> -->
	<bean id="userDao" class="com.dan.dao.impl.UserDao">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
</beans>

18.applicationContext_db.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!-- 配置sesionFactory-->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
	</bean> 
	<!-- 配置事物管理器bean -->
	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"/>
	</bean>
	<aop:config>
		<aop:pointcut id="entryPointMethod" expression="execution(* com.dan.service.impl.*.*(..))"/>
		<aop:advisor advice-ref="txAdvice" pointcut-ref="entryPointMethod"/>
	</aop:config>
	<aop:config>
		<aop:pointcut id="jobspacePointMethod" expression="execution(* com.dan.service.impl.*.*(..))"/>
		<aop:advisor advice-ref="txAdvice" pointcut-ref="jobspacePointMethod"/>
	</aop:config>
	<!-- 配置事物 -->
	<tx:advice id="txAdvice" transaction-manager="txManager">
		<tx:attributes>
			<tx:method name="create*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="add*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="delete*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="update*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="apply*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="save*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
		</tx:attributes>
	</tx:advice>
</beans>

19.applicationContext_service.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!--配置service层bean -->
	<bean id="userService" class="com.dan.service.impl.UserService">
		<property name="userDao" ref="userDao"></property>
	</bean>
	
</beans>

20.ehcache.xml
<ehcache>
    <diskStore path="java.io.tmpdir"/>
    <defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="120"
        overflowToDisk="true"
        />
    <cache name="com.happiness.pojo.APojo"
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="600"
        overflowToDisk="true"
        />
</ehcache>

21.hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<!-- 加载proxool数据库连接池 -->
		<property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
		<property name="hibernate.proxool.pool_alias">hp</property>
		<property name="hibernate.proxool.xml">proxool.xml</property>
		<!-- 自动生成数据表文件 -->
		<property name="hibernate.hbm2ddl.auto">update</property>
		<!--指定数据库语言 -->
		<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
		<!-- 显示sql语句 -->
		<property name="show_sql">true</property>
		
		<!-- 加载二级缓存 -->
		<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
		
		<!-- 加载hibernate映射文件 -->
		<!-- <mapping resource="com/tdtech/pdm/create/pojo/DQDocumentPojo.hbm.xml" /> -->
		<mapping resource="com/dan/entity/User.hbm.xml" />
		<mapping resource="com/dan/entity/AskForLeave.hbm.xml" />
		<mapping resource="com/dan/entity/ProcessPicture.hbm.xml" />
	</session-factory>
</hibernate-configuration>
我的工作流demo-3
12.CharsetEncodingFilter.java
package com.dan.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CharsetEncodingFilter implements Filter{
	/**
	 * 销毁方法
	 */
	public void destroy() {
		
	}
	/**
	 * 字符乱码处理方法
	 */
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		HttpServletResponse response=(HttpServletResponse)res;
		HttpServletRequest request=(HttpServletRequest)req;
		String name=request.getMethod();  //name为请求方式
		if("post".equalsIgnoreCase(name)){
			request.setCharacterEncoding("UTF-8");
			chain.doFilter(request, response);
		}else{
			CharsetEncodingUtil charsetEncodingUtil=new CharsetEncodingUtil(request);
			chain.doFilter(charsetEncodingUtil, response);
		}
	}
	/**
	 * 初始化方法
	 */
	public void init(FilterConfig arg0) throws ServletException {
		
	}

}


13.CharsetEncodingUtil.java
package com.dan.util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
public class CharsetEncodingUtil extends HttpServletRequestWrapper{
	private HttpServletRequest request;
	public CharsetEncodingUtil(HttpServletRequest request){
		super(request);
		this.request=request;
	}
	public String getParameter(String name) { //name为从页面传过来的请求参数
		String nameValue=request.getParameter(name);
		try{
			//对请求的参数进行转码处理
			if(nameValue!=null){
				nameValue=new String(nameValue.getBytes("ISO-8859-1"),"UTF-8");
			}
			return nameValue;
		}catch(Exception e){
			e.printStackTrace();
		}
		return super.getParameter(name);
	}
}

14.DeployFlowAction.java
package com.hp.action;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

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

import org.apache.struts2.ServletActionContext;

import com.dan.entity.AskForLeave;
import com.dan.entity.ProcessPicture;
import com.dan.service.IUserService;

public class DeployFlowAction {
	private HttpServletRequest request;
	private List<AskForLeave> taskList;
	private AskForLeave askForLeave;
	private ProcessPicture processPicture;
	private IUserService userService;
	private String title;
	
	/**
	 * 查询审批记录
	 */
	public String audit(){
		request = ServletActionContext.getRequest();
		String auditResult = request.getParameter("auditResult");
		
		//查询待审批的请假记录
		if(2 == askForLeave.getCurrentNodeNum()){ //主管审批
			if("true".equals(auditResult)){
				if(askForLeave.getAflDays() > 10){
					askForLeave.setCurrentNodeNum(4);
				}else{
					askForLeave.setCurrentNodeNum(3);
				}
				askForLeave.setAuditStatus("ZG Approved");
			}else{
				askForLeave.setAuditStatus("ZG Refused");
				askForLeave.setCurrentNodeNum(5);
			}
			
		}else if(3 == askForLeave.getCurrentNodeNum()){ //经理审批
			if("true".equals(auditResult)){
				askForLeave.setAuditStatus("MG Approved");
			}else{
				askForLeave.setAuditStatus("MG Refused");
			}
			askForLeave.setCurrentNodeNum(5);
		}else if(4 == askForLeave.getCurrentNodeNum()){ //老板审批
			if("true".equals(auditResult)){
				askForLeave.setAuditStatus("BG Approved");
			}else{
				askForLeave.setAuditStatus("BG Refused");
			}
			askForLeave.setCurrentNodeNum(5);
		}
		boolean flg = userService.update(askForLeave);
		System.out.println("审批结果:"+flg);
		return null;
	}
	
	/**
	 * 查询审批记录
	 */
	public String query(){
		request = ServletActionContext.getRequest();
		String act = request.getParameter("act");
		String id = request.getParameter("id");
		//查询待审批的请假记录
		askForLeave = userService.findAskForLeave(id);
		title = "";
		if("2".equals(act)){ //主管审批
			title = "主管审批";
		}else if("3".equals(act)){ //经理审批
			title = "经理审批";
		}else if("4".equals(act)){ //老板审批
			title = "老板审批";
		}
		return "audit";
	}
	
	/**
	 * 查看待办任务列表
	 */
	public String waitingTask(){
		taskList = userService.queryWaitForAskForLeave(); //查看待办的请假列表
		return "waitingTask";
	}
	
	/**
	 * 查看已办任务列表
	 */
	public String historyTask(){
		taskList = userService.queryHistoryForAskForLeave(); //查看待办的请假列表
		return "waitingTask";
	}
	
	/**
	 * 查看图片
	 */
	public void showImg() throws Exception{
		request = ServletActionContext.getRequest();
		HttpServletResponse response = ServletActionContext.getResponse();
		InputStream inputStream = new FileInputStream("D:\\twx162737\\test\\qj.png");
		byte[] b = new byte[1024];
		int len = -1;
		try {
			while ((len = inputStream.read(b, 0, 1024)) != -1) {
				response.getOutputStream().write(b, 0, len);
			}
			response.getOutputStream().flush();  
			response.getOutputStream().close(); 
			inputStream.close(); 
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 显示当前活动所在的结点
	 * @return
	 */
	public String showPictureNode(){
		request = ServletActionContext.getRequest();
		String id = request.getParameter("id");
		System.out.println("流程当前节点为: "+id);
		processPicture = userService.query(id);
		request.setAttribute("id", processPicture.getId()); //id为0表示当前流程处在开始节点
		request.setAttribute("X", processPicture.getNodeLocation_x());
		request.setAttribute("Y", processPicture.getNodeLocation_y());
		request.setAttribute("width", processPicture.getNodeLocation_w());
		request.setAttribute("height", processPicture.getNodeLocation_h());
		return "showPic";
	}
	/**
	 * 请假申请
	 */
	public String apply() throws Exception{
		this.askForLeave.setAuditStatus("Aplied");
		this.askForLeave.setCurrentNodeNum(2); //设置流程所处的节点为开始节点的下一个节点处
		boolean flg = this.userService.apply(askForLeave);
		System.out.println("提交申请成功与否:"+flg);
		return null;
	}
	public HttpServletRequest getRequest() {
		return request;
	}
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	public List<AskForLeave> getTaskList() {
		return taskList;
	}
	public void setTaskList(List<AskForLeave> taskList) {
		this.taskList = taskList;
	}
	public AskForLeave getAskForLeave() {
		return askForLeave;
	}
	public void setAskForLeave(AskForLeave askForLeave) {
		this.askForLeave = askForLeave;
	}
	public IUserService getUserService() {
		return userService;
	}
	public void setUserService(IUserService userService) {
		this.userService = userService;
	}
	public ProcessPicture getProcessPicture() {
		return processPicture;
	}
	public void setProcessPicture(ProcessPicture processPicture) {
		this.processPicture = processPicture;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}
我的工作流demo-2
6.User.java
package com.dan.entity;


import java.io.Serializable;

 
/**
 * 实体类
 * @author zdd
 *
 */
public class User implements Serializable {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	
	private String name;
	
	private String age;
	
	public User(){
		
	}
	
	public User(String name,String age){
		this.name = name;
		this.age = age;
	}

	
	public Integer getId() {
		return id;
	}

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

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}
}

7.AskForLeave.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.dan.entity">
	<class name="AskForLeave" table="tb_ask_for_leave">
		<id name="id">
			<generator class="native"></generator>
		</id>
		<property name="aflName"></property>
		<property name="aflDays"></property>
		<property name="auditStatus"></property>
		<property name="firstAuditPeople"></property>
		<property name="secondAuditPeople"></property>
		<property name="aflDesc"></property>
		<property name="currentNodeNum"></property>
		<property name="auditPeople"></property>
	</class>
</hibernate-mapping>

8.ProcessPicture.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.dan.entity">
	<class name="ProcessPicture" table="tb_process_picture">
		<id name="id">
			<generator class="native"></generator>
		</id>
		<property name="nodeName"></property>
		<property name="nodeLocation_x"></property>
		<property name="nodeLocation_y"></property>
		<property name="nodeLocation_w"></property>
		<property name="nodeLocation_h"></property>
	</class>
</hibernate-mapping>

9.User.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.dan.entity">
	<class name="User" table="tb_user">
		<id name="id">
			<generator class="native"></generator>
		</id>
		<property name="name"></property>
		<property name="age"></property>
		<!-- 多对多 -->
		<!-- <set name="users" cascade="all" table="tb_user_action">
			<key column="actionId"></key>
			<many-to-many class="UserPojo" column="userId"></many-to-many>
		</set> -->
	</class>
</hibernate-mapping>

10.IUserService.java
package com.dan.service;

import java.util.List;

import com.dan.entity.AskForLeave;
import com.dan.entity.ProcessPicture;
import com.dan.entity.User;

public interface IUserService {

	public void addUser(User user);
	public boolean apply(AskForLeave askForLeave);
	public List<AskForLeave> queryWaitForAskForLeave();
	public ProcessPicture  query(String currentNodeNumStr);
	public AskForLeave findAskForLeave(String id);
	public boolean update(AskForLeave askForLeave);
	public List<AskForLeave> queryHistoryForAskForLeave();
}

11.UserService.java
package com.dan.service.impl;

import java.util.List;

import com.dan.dao.IUserDao;
import com.dan.entity.AskForLeave;
import com.dan.entity.ProcessPicture;
import com.dan.entity.User;
import com.dan.service.IUserService;

public class UserService implements IUserService {
	private IUserDao userDao;
	
	@Override
	public void addUser(User user) {
		userDao.addUser(user);
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public boolean apply(AskForLeave askForLeave) {
		return userDao.apply(askForLeave);
	}

	@Override
	public List<AskForLeave> queryWaitForAskForLeave() {
		return userDao.queryWaitForAskForLeave();
	}

	@Override
	public ProcessPicture query(String currentNodeNumStr) {
		Integer currentNodeNum = Integer.valueOf(currentNodeNumStr);
		return userDao.query(currentNodeNum);
	}

	@Override
	public AskForLeave findAskForLeave(String idStr) {
		Integer id = Integer.valueOf(idStr);
		return userDao.findAskForLeave(id);
	}

	@Override
	public boolean update(AskForLeave askForLeave) {
		return userDao.update(askForLeave);
	}

	@Override
	public List<AskForLeave> queryHistoryForAskForLeave() {
		return userDao.queryHistoryForAskForLeave();
	}

}
我的工作流demo-01
1.UserAction.java
package com.dan.action;

import com.dan.entity.User;
import com.dan.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * UserAction类
 * @author zdd
 *
 */
public class UserAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1853360186599729298L;

	private IUserService userService;
	
	private User user;
	//显示添加页面
	public String showAddUser(){
		return "showAddUser";
	}
	
	//添加用户
	public String addUser() throws Exception{
		System.out.println(user.getName()+", "+user.getAge());
		userService.addUser(user);
		
		return "success";
	}
	
	public IUserService getUserService() {
		return userService;
	}

	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}

2.IUserDao.java
package com.dan.dao;

import java.util.List;

import com.dan.entity.AskForLeave;
import com.dan.entity.ProcessPicture;
import com.dan.entity.User;

/**
 * UserDao接口
 * @author zdd
 *
 */
public interface IUserDao {
	
	public void addUser(User user);
	public boolean apply(AskForLeave askForLeave);
	public List<AskForLeave> queryWaitForAskForLeave();
	public ProcessPicture query(Integer currentNodeNum);
	public AskForLeave findAskForLeave(Integer id);
	public boolean update(AskForLeave askForLeave);
	public List<AskForLeave> queryHistoryForAskForLeave();
}

3.UserDao.java
package com.dan.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;

import com.dan.dao.IUserDao;
import com.dan.entity.AskForLeave;
import com.dan.entity.ProcessPicture;
import com.dan.entity.User;

/**
 * UserDao
 * @author zdd
 *
 */
public class UserDao implements IUserDao {

	//调用注入的sessionFactory
	private SessionFactory sessionFactory;
	
	@Override
	public void addUser(User user) {
		System.out.println(user.getName()+", "+user.getAge());
		Session session = sessionFactory.openSession();
		session.getTransaction().begin();
		session.save(user);
		session.getTransaction().commit();
		session.close();
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	@Override
	public boolean apply(AskForLeave askForLeave) {
		try{
			System.out.println(askForLeave.getAflName()+", "+askForLeave.getAflDays());
			Session session = sessionFactory.openSession();
			session.getTransaction().begin();
			session.save(askForLeave);
			session.getTransaction().commit();
			session.close();
			return true;
		}catch(Exception e){
			return false;
		}
	}

	@Override
	public List<AskForLeave> queryWaitForAskForLeave() {
		Session session = sessionFactory.openSession();
		List<AskForLeave> list = session.createQuery("from AskForLeave where auditStatus in ('Aplied','ZG Approved') ").list();
		return list;
	}

	@Override
	public ProcessPicture query(Integer currentNodeNum) {
		Session session = sessionFactory.openSession();
		ProcessPicture pp = (ProcessPicture) session.createQuery("from ProcessPicture where id = "+currentNodeNum).list().get(0);
		return pp;
	}

	@Override
	public AskForLeave findAskForLeave(Integer id) {
		Session session = sessionFactory.openSession();
		AskForLeave asl = (AskForLeave) session.get(AskForLeave.class, id);
		return asl;
	}

	@Override
	public boolean update(AskForLeave askForLeave) {
		try{
			Session session = sessionFactory.openSession();
			AskForLeave asl = (AskForLeave) session.get(AskForLeave.class, askForLeave.getId());
			asl.setAuditStatus(askForLeave.getAuditStatus());
			asl.setCurrentNodeNum(askForLeave.getCurrentNodeNum());
			session.beginTransaction();
			session.update(asl);
			session.getTransaction().commit();
			return true;
		}catch(Exception e){
			return false;
		}
	}

	@Override
	public List<AskForLeave> queryHistoryForAskForLeave() {
		Session session = sessionFactory.openSession();
		List<AskForLeave> list = session.createQuery("from AskForLeave where auditStatus in ('BG Approved','MG Approved','ZG Refused','MG Refused','BG Refused') ").list();
		return list;
	}

}

4.AskForLeave.java
package com.dan.entity;
/**对应请假表*/
public class AskForLeave {
	private Integer id;
	private String aflName; //请假人
	private Double aflDays; //请假天数
	private String auditStatus; //审批状态Aplied 
	private String firstAuditPeople; //一级审批人
	private String secondAuditPeople; //二级审批人
	private String auditPeople; //审批人
	private String aflDesc; //请假描述
	private Integer currentNodeNum; //流程所处的节点编号
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getAflName() {
		return aflName;
	}
	public void setAflName(String aflName) {
		this.aflName = aflName;
	}
	public Double getAflDays() {
		return aflDays;
	}
	public void setAflDays(Double aflDays) {
		this.aflDays = aflDays;
	}
	public String getAuditStatus() {
		return auditStatus;
	}
	public void setAuditStatus(String auditStatus) {
		this.auditStatus = auditStatus;
	}
	public String getFirstAuditPeople() {
		return firstAuditPeople;
	}
	public void setFirstAuditPeople(String firstAuditPeople) {
		this.firstAuditPeople = firstAuditPeople;
	}
	public String getSecondAuditPeople() {
		return secondAuditPeople;
	}
	public void setSecondAuditPeople(String secondAuditPeople) {
		this.secondAuditPeople = secondAuditPeople;
	}
	public String getAflDesc() {
		return aflDesc;
	}
	public void setAflDesc(String aflDesc) {
		this.aflDesc = aflDesc;
	}
	public Integer getCurrentNodeNum() {
		return currentNodeNum;
	}
	public void setCurrentNodeNum(Integer currentNodeNum) {
		this.currentNodeNum = currentNodeNum;
	}
	public String getAuditPeople() {
		return auditPeople;
	}
	public void setAuditPeople(String auditPeople) {
		this.auditPeople = auditPeople;
	}
}

5.ProcessPicture.java
package com.dan.entity;
/**
 * 流程图持久类
 */
public class ProcessPicture {
	private Integer id;
	private String nodeName; //节点名称
	private Integer nodeLocation_x; //节点x坐标
	private Integer nodeLocation_y; //节点y坐标
	private Integer nodeLocation_w; //宽度
	private Integer nodeLocation_h; //高度
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getNodeName() {
		return nodeName;
	}
	public void setNodeName(String nodeName) {
		this.nodeName = nodeName;
	}
	public Integer getNodeLocation_x() {
		return nodeLocation_x;
	}
	public void setNodeLocation_x(Integer nodeLocation_x) {
		this.nodeLocation_x = nodeLocation_x;
	}
	public Integer getNodeLocation_y() {
		return nodeLocation_y;
	}
	public void setNodeLocation_y(Integer nodeLocation_y) {
		this.nodeLocation_y = nodeLocation_y;
	}
	public Integer getNodeLocation_w() {
		return nodeLocation_w;
	}
	public void setNodeLocation_w(Integer nodeLocation_w) {
		this.nodeLocation_w = nodeLocation_w;
	}
	public Integer getNodeLocation_h() {
		return nodeLocation_h;
	}
	public void setNodeLocation_h(Integer nodeLocation_h) {
		this.nodeLocation_h = nodeLocation_h;
	}
	
}

自己整合的--S2SH+JBPM4.4 demo--05
25.success.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>success</title>
</head>
<body>
	success!!!
</body>
</html>

26.deploy.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/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>
	<c:forEach var="deployProcess" items="deployProcesses">
		<tr>
			<td>${deployProcess.id}</td>
			<td>${deployProcess.name}</td>
			<td>${deployProcess.version}</td>
			<td><a href="">流程删除</a></td>
			<td><a href="">启动流程</a></td>
		</tr>
	</c:forEach>
</body>
</html>

27.error.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>error</title>
</head>
<body>
	error!!!
</body>
</html>


28.jar包有:
activation.jar
antlr-2.7.6.jar
aopalliance.jar
aspectjrt.jar
aspectjweaver.jar
backport-util-concurrent-3.1.jar
cglib-2.2.jar
commons-collections-3.1.jar
commons-dbcp.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging.jar
commons-logging-1.0.4.jar
commons-pool.jar
dom4j-1.6.1.jar
ehcache-1.5.0.jar
freemarker-2.3.15.jar
hibernate3.jar
james-2.3.2.jar
javassist-3.9.0.GA.jar
jbpm.jar
jdom.jar
jstl.jar
jta-1.1.jar
junit-4.4.jar
jxl.jar
mail.jar
mysql-connector-java-5.1.15-bin.jar
ognl-2.7.3.jar
org.springframework.aop-3.0.5.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar

org.springframework.aspects-3.0.5.RELEASE.jar
org.springframework.beans-3.0.5.RELEASE.jar
org.springframework.context.support-3.0.5.RELEASE.jar

org.springframework.context-3.0.5.RELEASE.jar
org.springframework.core-3.0.5.RELEASE.jar

org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.orm-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar

org.springframework.web.struts-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
proxool-0.9.0RC3.jar

servlet-api.jar
slf4j-api-1.6.1.jar
slf4j-nop-1.6.1.jar

standard.jar
struts2-core-2.1.8.1.jar
struts2-spring-plugin-2.1.8.1.jar
xwork-core-2.1.6.jar
自己整合的--S2SH+JBPM4.4 demo--04
20.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>
    <!-- 将struts2的Action交给Spring管理 -->
    <constant name="struts.objectFactory" value="spring" />
	<!-- 配置其他常量 -->
	<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
	<constant name="struts.i18n.encoding" value="UTF-8" />
	<constant name="struts.enable.DynamicMethodInvocation" value="true" />
	
	<!-- 用户模块的Action配置 -->
	<package name="struts_user" extends="struts-default" namespace="/user">
		<action name="user" class="userAction">
			<result name="success" type="redirect">/index.jsp</result>
			<!-- <result name="input">/login.jsp</result> -->
		</action>
	</package>
	
</struts>

21.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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <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>
   <filter>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter>
    <filter-name>charsetEncoding</filter-name>
    <filter-class>com.dan.util.CharsetEncodingFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>charsetEncoding</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

22.addUser.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>
	<h3>添加用户</h3>
	<form action="user/user!addUser" method="post">
		姓名: <input type="text" id="name" name="user.name"/><br /><br />
		年龄: <input type="text" id="age" name="user.age"/><br /><br />
		<input type="submit" value="添加"/>
	</form>
</body>
</html>

23.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>welcome</title>
<style type="text/css">
	#top{
		width:99%;
		height:50px;
		float:top;
		border-color:blue;
		border:1px solid;
	}
	#main{
		width:100%;
		height:84%;
		float:top;
		position:absolute;
	}
	#leftFrame{
		width:10%;
		height:100%;
		border:1px solid;
		float:left;
	}
	#rightFrame{
		width:88%;
		height:100%;
		border:1px solid;
		float:left;
	} 
	#treeDiv{
		margin-left:10%;
		background-color:white;
	}
	div{
		font-size:14px;
	}
	#bg_frame{
		background-color:lightblue;
	}
</style>
</head>
<body>
	<div id="top">事务管理系统</div>
	<div id="main">
		<div id="leftFrame">
			<div>
				<div id="bg_frame">我的代办任务</div>
				<div id="treeDiv"><a href="">审批处理</a></div>
			</div>
			<div>
				<div id="bg_frame">日常任务</div>
				<div id="treeDiv"><a href="qingjia.jsp">请假</a></div>
			</div>
		</div>
		<div id="rightFrame">
			主窗体内容
		</div> 
	</div>
</body>
</html>

24.qingjia.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>

</body>
</html>
自己整合的--S2SH+JBPM4.4 demo--03
13.applicationContext_db.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!-- 配置sesionFactory-->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
		<property name="mappingLocations">
			<list>
				<value>classpath:jbpm.execution.hbm.xml</value>
				<value>classpath:jbpm.history.hbm.xml</value>
				<value>classpath:jbpm.identity.hbm.xml</value>
				<value>classpath:jbpm.repository.hbm.xml</value>
				<value>classpath:jbpm.task.hbm.xml</value>
			</list>
		</property>
	</bean> 
	<!-- 配置事物管理器bean -->
	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"/>
	</bean>
	<aop:config>
		<aop:pointcut id="entryPointMethod" expression="execution(* com.dan.service.impl.*.*(..))"/>
		<aop:advisor advice-ref="txAdvice" pointcut-ref="entryPointMethod"/>
	</aop:config>
	<aop:config>
		<aop:pointcut id="jobspacePointMethod" expression="execution(* com.dan.service.impl.*.*(..))"/>
		<aop:advisor advice-ref="txAdvice" pointcut-ref="jobspacePointMethod"/>
	</aop:config>
	<!-- 配置事物 -->
	<tx:advice id="txAdvice" transaction-manager="txManager">
		<tx:attributes>
			<tx:method name="create*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="add*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="delete*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="update*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="apply*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
			<tx:method name="save*" isolation="READ_COMMITTED" propagation="REQUIRED" read-only="false" timeout="-1" />
		</tx:attributes>
	</tx:advice>
	<!-- 集成jbpm -->
	<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
		<property name="jbpmCfg" value="jbpm.cfg.xml" />  
	</bean>
	<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
</beans>

14.applicationContext_service.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!--配置service层bean -->
	<bean id="userService" class="com.dan.service.impl.UserService">
		<property name="userDao" ref="userDao"></property>
	</bean>
	
</beans>

15.ehcache.xml
<ehcache>
    <diskStore path="java.io.tmpdir"/>
    <defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="120"
        overflowToDisk="true"
        />
    <cache name="com.happiness.pojo.APojo"
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="600"
        overflowToDisk="true"
        />
</ehcache>

16.hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<!-- 加载proxool数据库连接池 -->
		<property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
		<property name="hibernate.proxool.pool_alias">hp</property>
		<property name="hibernate.proxool.xml">proxool.xml</property>
		<!-- 自动生成数据表文件 -->
		<property name="hibernate.hbm2ddl.auto">update</property>
		<!--指定数据库语言 -->
		<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
		<!-- 显示sql语句 -->
		<property name="show_sql">true</property>
		
		<!-- 加载二级缓存 -->
		<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
		
		<!-- 加载hibernate映射文件 -->
		<!-- <mapping resource="com/tdtech/pdm/create/pojo/DQDocumentPojo.hbm.xml" /> -->
		<mapping resource="com/dan/entity/User.hbm.xml" />
	</session-factory>
</hibernate-configuration>

17.jbpm.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>
  <import resource="jbpm.default.cfg.xml" />
  <import resource="jbpm.businesscalendar.cfg.xml" />
  <import resource="jbpm.tx.spring.cfg.xml" />
  <import resource="jbpm.jpdl.cfg.xml" />
  <import resource="jbpm.bpmn.cfg.xml" />
  <import resource="jbpm.identity.cfg.xml" />
</jbpm-configuration>

18.proxool.xml
<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
	<proxool>
		<!--连接池的别名 -->
		<alias>hp</alias>
		<!--proxool只能管理由自己产生的连接 -->
		<driver-url>jdbc:mysql://10.23.28.231:3306/db_ssh2jbpm</driver-url>
        <!-- JDBC驱动程序-->
		<driver-class>com.mysql.jdbc.Driver</driver-class>
		<driver-properties>
			<property name="user" value="root" />
			<property name="password" value="Td123456" />
		</driver-properties>
		
		<!-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回 收,超时的销毁 -->
		<house-keeping-sleep-time>90000</house-keeping-sleep-time>
		<!-- 指因未有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的 用户连接就不会被接受 -->
		<simultaneous-build-throttle>20</simultaneous-build-throttle>
		<!-- 最少保持的空闲连接数 -->
		<prototype-count>5</prototype-count>
		<!-- 允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的 等待请求数由maximum-new-connections决定 -->
		<maximum-connection-count>100</maximum-connection-count>
		<!-- 最小连接数 -->
		<minimum-connection-count>10</minimum-connection-count>
		<!-- add time: 2013-5-14 begin -->
		<test-before-use>true</test-before-use>
		<test-after-use>true</test-after-use>
		<house-keeping-test-sql>SELECT CURRENT_USER</house-keeping-test-sql>
		<!-- add time: 2013-5-14 end -->
	</proxool>
</something-else-entirely>

19.struts.properties
struts.multipart.maxSize=314572800
自己整合的--S2SH+JBPM4.4 demo--02
8.CharsetEncodingFilter.java
package com.dan.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CharsetEncodingFilter implements Filter{
	/**
	 * 销毁方法
	 */
	public void destroy() {
		
	}
	/**
	 * 字符乱码处理方法
	 */
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		HttpServletResponse response=(HttpServletResponse)res;
		HttpServletRequest request=(HttpServletRequest)req;
		String name=request.getMethod();  //name为请求方式
		if("post".equalsIgnoreCase(name)){
			request.setCharacterEncoding("UTF-8");
			chain.doFilter(request, response);
		}else{
			CharsetEncodingUtil charsetEncodingUtil=new CharsetEncodingUtil(request);
			chain.doFilter(charsetEncodingUtil, response);
		}
	}
	/**
	 * 初始化方法
	 */
	public void init(FilterConfig arg0) throws ServletException {
		
	}

}

9.CharsetEncodingUtil.java
package com.dan.util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
public class CharsetEncodingUtil extends HttpServletRequestWrapper{
	private HttpServletRequest request;
	public CharsetEncodingUtil(HttpServletRequest request){
		super(request);
		this.request=request;
	}
	public String getParameter(String name) { //name为从页面传过来的请求参数
		String nameValue=request.getParameter(name);
		try{
			//对请求的参数进行转码处理
			if(nameValue!=null){
				nameValue=new String(nameValue.getBytes("ISO-8859-1"),"UTF-8");
			}
			return nameValue;
		}catch(Exception e){
			e.printStackTrace();
		}
		return super.getParameter(name);
	}
}

10.DeployFlowAction.java
package com.hp.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;

public class DeployFlowAction {
	private ProcessEngine processEngine;
	private ExecutionService executionService;
	private HttpServletRequest request;
	private List<ProcessDefinition> deployProcesses;
	/**
	 * 部署流程定义
	 */
	public String deploy() throws Exception{
		System.out.println("部署流程定义-action");
		RepositoryService repositoryService = this.processEngine.getRepositoryService();
		//部署流程定义
		repositoryService.createDeployment().addResourceFromClasspath("com/hp/test/process.jpdl.xml").deploy();
		deployProcesses = repositoryService.createProcessDefinitionQuery().list();
		return null;
	}
	/**
	 * 启动流程 
	 */
	public String startProcess(){
		executionService = this.processEngine.getExecutionService();
		executionService.startProcessInstanceById(request.getParameter("id"));
		return null;
	}
	public ProcessEngine getProcessEngine() {
		return processEngine;
	}
	public void setProcessEngine(ProcessEngine processEngine) {
		this.processEngine = processEngine;
	}
	public ExecutionService getExecutionService() {
		return executionService;
	}
	public void setExecutionService(ExecutionService executionService) {
		this.executionService = executionService;
	}
	public HttpServletRequest getRequest() {
		return request;
	}
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	public List<ProcessDefinition> getDeployProcesses() {
		return deployProcesses;
	}
	public void setDeployProcesses(List<ProcessDefinition> deployProcesses) {
		this.deployProcesses = deployProcesses;
	}
}


11.applicationContext_action.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!--Action bean -->
	<!-- 给action添加scope属性用来避免spring创建单例,这样防止线程不安全 -->
	<!-- <bean id="dQDocumentAction" class="com.tdtech.pdm.create.action.DQDocumentAction" scope="prototype">
		<property name="dQDocumentServiceImpl" ref="dQDocumentServiceImpl"></property>
	</bean>  -->
	<bean id="deployFlowAction" class="com.hp.action.DeployFlowAction" scope="prototype">
		<property name="processEngine" ref="processEngine"></property>
	</bean>
	<bean id="userAction" class="com.dan.action.UserAction">
		<property name="userService" ref="userService"></property>
		<property name="processEngine" ref="processEngine"></property>
	</bean>
</beans>

12.applicationContext_dao.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:aop="http://www.springframework.org/schema/aop"
		  xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
               	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               	http://www.springframework.org/schema/context
			   	http://www.springframework.org/schema/context/spring-context-3.0.xsd
			  	http://www.springframework.org/schema/tx
				http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
				http://www.springframework.org/schema/aop
				http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!-- 配置HibernateTemplate bean -->
	<!-- <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean> -->
	<!-- 配置Dao层bean -->
	<!-- <bean id="dQDocumentDaoImpl" class="com.tdtech.pdm.create.dao.impl.DQDocumentDaoImpl">
		<property name="hibernateTemplate" ref="hibernateTemplate"></property>
	</bean> -->
	<bean id="userDao" class="com.dan.dao.impl.UserDao">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
</beans>
自己整合的--S2SH+JBPM4.4 demo--01
1.UserAction.java
package com.dan.action;

import org.jbpm.api.ProcessEngine;

import com.dan.entity.User;
import com.dan.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * UserAction类
 * @author zdd
 *
 */
public class UserAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1853360186599729298L;

	private IUserService userService;
	
	private User user;
	
	private ProcessEngine processEngine;
	
	//显示添加页面
	public String showAddUser(){
		return "showAddUser";
	}
	
	//添加用户
	public String addUser() throws Exception{
		System.out.println(user.getName()+", "+user.getAge());
		userService.addUser(user);
		
		return "success";
	}

	//测试JBPM
	public String testJbpm() throws Exception{
		System.out.println("整合成功");
		System.out.println("processEngine =========== " + processEngine);
		return "success";
	}
	public IUserService getUserService() {
		return userService;
	}

	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public ProcessEngine getProcessEngine() {
		return processEngine;
	}

	public void setProcessEngine(ProcessEngine processEngine) {
		this.processEngine = processEngine;
	}
}


2.IUserDao.java
package com.dan.dao;

import com.dan.entity.User;

/**
 * UserDao接口
 * @author zdd
 *
 */
public interface IUserDao {
	
	public void addUser(User user);

}

3.UserDao.java
package com.dan.dao.impl;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;

import com.dan.dao.IUserDao;
import com.dan.entity.User;

/**
 * UserDao
 * @author zdd
 *
 */
public class UserDao implements IUserDao {

	//调用注入的sessionFactory
	private SessionFactory sessionFactory;
	
	@Override
	public void addUser(User user) {
		System.out.println(user.getName()+", "+user.getAge());
		Session session = sessionFactory.openSession();
		session.getTransaction().begin();
		session.save(user);
		session.getTransaction().commit();
		session.close();
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

}

4.User.java
package com.dan.entity;


import java.io.Serializable;

 
/**
 * 实体类
 * @author zdd
 *
 */
public class User implements Serializable {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	
	private String name;
	
	private String age;
	
	public User(){
		
	}
	
	public User(String name,String age){
		this.name = name;
		this.age = age;
	}

	
	public Integer getId() {
		return id;
	}

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

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}
}

5.User.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.dan.entity">
	<class name="User" table="tb_user">
		<id name="id">
			<generator class="native"></generator>
		</id>
		<property name="name"></property>
		<property name="age"></property>
		<!-- 多对多 -->
		<!-- <set name="users" cascade="all" table="tb_user_action">
			<key column="actionId"></key>
			<many-to-many class="UserPojo" column="userId"></many-to-many>
		</set> -->
	</class>
</hibernate-mapping>

6.IUserService.java
package com.dan.service;

import com.dan.entity.User;

public interface IUserService {

	public void addUser(User user);
	
}


7.UserService.java
package com.dan.service.impl;

import com.dan.dao.IUserDao;
import com.dan.entity.User;
import com.dan.service.IUserService;

public class UserService implements IUserService {
	private IUserDao userDao;
	
	@Override
	public void addUser(User user) {
		userDao.addUser(user);
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

}
jquery-uploadify批量上传
1. upload2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    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" "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>
		<base href="<%=basePath%>">
		<link href="<%=basePath%>uploadify2/uploadify.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="<%=basePath%>uploadify2/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="<%=basePath%>uploadify2/swfobject.js"></script>
		<script type="text/javascript" src="<%=basePath%>uploadify2/jquery.uploadify.v2.1.4.min.js"></script>
	</head>
<body>
<div id="fileQueue"></div>
	<input type="file" name="uploadify" id="uploadify" />
    <p>
        <a href="javascript: jQuery('#uploadify').uploadifyUpload()">开始上传</a> 
		<a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">取消所有上传</a>
	</p>
</body>
<script type="text/javascript">
	//官方网址:http://www.uploadify.com/
	$(document).ready(function(){
		//$("#uploadify").uploadifySettings('scriptData',	{'name':'liudong','age':22});
		$("#uploadify").uploadify({
			'uploader'	:	"<%=basePath%>uploadify2/uploadify.swf",
			'script'    :	"<%=basePath%>/servlet/UploadPhotoServlet",
			'cancelImg' :	"<%=basePath%>uploadify2/cancel.png",
			'folder'	:	"uploads",//上传文件存放的路径,请保持与uploadFile.jsp中PATH的值相同
			'queueId'	:	"fileQueue",
			'queueSizeLimit'	:	10,//限制上传文件的数量
			'fileExt'	:	"*.rar,*.zip,*.png,*.txt",
			//'fileDesc'	:	"RAR *.rar",//限制文件类型
			'auto'		:	false,
			'multi'		:	true,//是否允许多文件上传
			'simUploadLimit':	2,//同时运行上传的进程数量
			'buttonText':	"files",
			//'scriptData':	{'name':'liudong','age':22},//这个参数用于传递用户自己的参数,此时'method' 必须设置为GET, 后台可以用request.getParameter('name')获取名字的值
			'method'	:	"GET"
		});
		
		//$("#uploadify").uploadifySettings();
	});
</script>
</html>

2. UploadPhotoServlet.java
package com.org.servlet;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

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

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import com.db.ReadTxtUtil;


@SuppressWarnings("serial")
public class UploadPhotoServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public UploadPhotoServlet() {
		super();
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out
				.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("  <BODY>");
		out.print("    This is ");
		out.print(this.getClass());
		out.println(", using the GET method");
		out.println("  </BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		String savePath = this.getServletConfig().getServletContext().getRealPath("");
		System.out.print("-----"+savePath);
		savePath = savePath+"/uploads/";
		System.out.println("上传路径:"+savePath);
		File f1 = new File(savePath);
		if(!f1.exists()){
			f1.mkdirs();
		}
		DiskFileItemFactory fac = new DiskFileItemFactory();
		ServletFileUpload upload = new ServletFileUpload(fac);
		upload.setHeaderEncoding("utf-8");
		List fileList = null;
		try {
			fileList = upload.parseRequest(req);
		} catch (FileUploadException e) {
			e.printStackTrace();
		}
		if(fileList==null){
			resp.getWriter().print("No file upload!");
			return;
		}
		Iterator<FileItem> it = fileList.iterator();
		String name = "";
		String extName = "";
		while(it.hasNext()){
			FileItem item = it.next();
			if(!item.isFormField()){//isFormField介绍:true=表单输入 域,false=文件上传域。
				name = item.getName();
				//long size = item.getSize();
				//String type = item.getContentType();
				if(name == null || name.trim().equals("")){
					continue;
				}
				//扩展名格式
				if(name.lastIndexOf(".")>=0){
					extName = name.substring(name.lastIndexOf("."));
				}
				File file = null;
				do{
					//生成文件名
//					name = UUID.randomUUID().toString();
					Date date = new Date();
					DateFormat df = new SimpleDateFormat("yyyyMMddkkmmssSS");
					name = name.substring(0, name.lastIndexOf(".")) + "_"+df.format(date);
					file = new File(savePath+name+extName);
				}while(file.exists());
				File saveFile = new File(savePath+name+extName);
				try {
					item.write(saveFile);
					ReadTxtUtil rtu = new ReadTxtUtil();
					Map<String, String> uploadProReconMap = rtu.readUploadFile(new FileInputStream(saveFile));
					Map<String, String> proReconNameMap = rtu.getProReconNameMap(new BufferedReader(new FileReader(new File("D:\\codefile\\testfile\\PRoReconConstant.txt"))));
					Map<String, String> proReconMap = new LinkedHashMap<String, String>();
					for(Map.Entry<String, String> obj : uploadProReconMap.entrySet()){
						String key = obj.getKey();
						String value = obj.getValue();
						if(proReconNameMap.containsKey(key)){
							proReconMap.put(proReconNameMap.get(key), value);
						}
					}
					System.out.println("*********话说白骨精与孙悟空的恋情-begin");
					for(Map.Entry<String, String> obj : proReconMap.entrySet()){
						System.out.println(obj.getKey()+"="+obj.getValue());
					}
					System.out.println("*********话说白骨精与孙悟空的恋情-end");
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		resp.getWriter().print(name+extName);
		
	}

}

3. ReadTxtUtil.java
package com.db;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

public class ReadTxtUtil {
	public Map<String , String> readUploadFile(FileInputStream fis){
		Map<String, String> map = new LinkedHashMap<String, String>();
		try {
			Workbook wb = WorkbookFactory.create(fis);
			Sheet sheet = wb.getSheetAt(1);
			for(int i = 3; i < sheet.getLastRowNum(); i++){
				Row r = sheet.getRow(i);
				Cell c1 = r.getCell(1);
				Cell c2 = r.getCell(2);
				System.out.println(c1.toString()+"="+c2.toString());
				map.put(c1.toString(), c2.toString());
			}
		} catch (InvalidFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}
	public Map<String,String> getProReconNameMap(BufferedReader br){
		Map<String,String> map = new LinkedHashMap<String, String>();
		try{
			String s = null;
			while((s = br.readLine()) != null){
				if(s.contains("proReconFileName")){
					continue;
				}
				String[] st = s.split("=");
				map.put(st[0].trim(), st[1].trim());
				System.out.println(s);
			}
			br.close();
		}catch(Exception e){
			return null;
		}
		return map;
	} 
	public static void main(String[] args){
		File file = new File("D:\\codefile\\testfile\\PRoReconConstant.txt");
		BufferedReader br = null;
		try {
			br = new BufferedReader(new FileReader(file));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Map<String, String> map = new ReadTxtUtil().getProReconNameMap(br);
		System.out.println(map.size());
	}
}

4. 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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>demo1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
   <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>UploadPhotoServlet</servlet-name>
    <servlet-class>com.org.servlet.UploadPhotoServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>UploadPhotoServlet</servlet-name>
    <url-pattern>/servlet/UploadPhotoServlet</url-pattern>
  </servlet-mapping>
</web-app>
jdbc连接数据库23
1. 表t_proReconRecord的结构定义:
	prr_id int ; //主键
	contract_id int ; //合同号
	ttr_id int ; //解决方案id
	sell_id int; //网元
	pr_values text ; //工勘信息
	webModelDetail varchar ; //细分的网元类型
	config_id int; //bill清单编号

2. ProjectReconRecord.java
package com.pojo;
/**
 * 工勘记录表
 */
public class ProjectReconRecord {
	private Integer prr_id; //主键
	private Integer contract_id; //合同号
	private Integer ttr_id; //解决方案id
	private Integer sell_id; //网元
	private String pr_values; //工勘信息
	private String webModelDetail; //细分的网元类型
	private Integer config_id; //bill清单编号
	public Integer getPrr_id() {
		return prr_id;
	}
	public void setPrr_id(Integer prr_id) {
		this.prr_id = prr_id;
	}
	public Integer getContract_id() {
		return contract_id;
	}
	public void setContract_id(Integer contract_id) {
		this.contract_id = contract_id;
	}
	public String getPr_values() {
		return pr_values;
	}
	public void setPr_values(String pr_values) {
		this.pr_values = pr_values;
	}
	public Integer getTtr_id() {
		return ttr_id;
	}
	public void setTtr_id(Integer ttr_id) {
		this.ttr_id = ttr_id;
	}
	public Integer getSell_id() {
		return sell_id;
	}
	public void setSell_id(Integer sell_id) {
		this.sell_id = sell_id;
	}
	public String getWebModelDetail() {
		return webModelDetail;
	}
	public void setWebModelDetail(String webModelDetail) {
		this.webModelDetail = webModelDetail;
	}
	public Integer getConfig_id() {
		return config_id;
	}
	public void setConfig_id(Integer config_id) {
		this.config_id = config_id;
	}
}

3. DBUtil.java
package com.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class DBUtil {
	private Connection conn;
	private PreparedStatement ps;
	private ResultSet rs;
	public Connection getConn() {
		return conn;
	}
	public PreparedStatement getPs() {
		return ps;
	}
	public ResultSet getRs() {
		return rs;
	}
	public Connection getConnection(){
		try{
			String username = "root";
			String password = "dfd12df";
			String url = "jdbc:mysql://localhost:3306/db_hp";
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url, username, password);
			System.out.println("数据库连接成功");
		}catch(Exception e){
			conn = null;
		}
		return conn;
	}
	public PreparedStatement getPreparedStatement(String sql){
		try{
			ps = conn.prepareStatement(sql);
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}
	public ResultSet getResultSet(){
		try{
			rs = ps.executeQuery();
		}catch(Exception e){
			e.printStackTrace();
		}
		return rs;
	}
	public void close(){
		try{
			if(rs != null){
				rs.close();
			}
			if(ps != null){
				ps.close();
			}
			if(conn != null){
				conn.close();
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public static void main(String[] args){
		DBUtil du = new DBUtil();
		du.getConnection();
	}
}

4. CommonDB.java
package com.db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.pojo.ProjectReconRecord;

public class CommonDB<T> {
	private T t;
	public void setT(T t){
		this.t = t;
	}
	public T getT(){
		return this.t;
	}
	/**查询数据库*/
	public List<?> findListBySql(T t, String sql){
		this.setT(t);
		List<ProjectReconRecord> list = new ArrayList<ProjectReconRecord>();
		DBUtil du = new DBUtil();
		du.getConnection();
		du.getPreparedStatement(sql);
		ResultSet rs = du.getResultSet();
		try{
			ProjectReconRecord p = null;
			/** 1为ProjectReconRecord */
			int flg = 0;
			if(this.getT().getClass().equals(ProjectReconRecord.class)){
				flg = 1;
			}
			while(rs.next()){
				if(flg == 1){
					p = new ProjectReconRecord();
					Integer prr_id = rs.getInt("prr_id");
					Integer contract_id = rs.getInt("contract_id");
					Integer ttr_id = rs.getInt("ttr_id");
					Integer sell_id = rs.getInt("sell_id");
					String pr_values = rs.getString("pr_values");
					Integer config_id = rs.getInt("config_id");
					p.setPrr_id(prr_id);
					p.setContract_id(contract_id);
					p.setTtr_id(ttr_id);
					p.setSell_id(sell_id);
					p.setPr_values(pr_values);
					p.setConfig_id(config_id);
					list.add(p);
					continue;
				}else{
					break;
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			du.close();
		}
		System.out.println("rs是否关闭?"+(du.getRs()==null?"是":"否"));
		System.out.println("ps是否关闭?"+(du.getPs()==null?"是":"否"));
		System.out.println("conn是否关闭?"+(du.getConn()==null?"是":"否"));
		return list;
	}
	public static void main(String[] args) {
		CommonDB<ProjectReconRecord> cd = new CommonDB<ProjectReconRecord>();
		cd.setT(new ProjectReconRecord());
		List<ProjectReconRecord> list = (List<ProjectReconRecord>) cd.findListBySql(new ProjectReconRecord(), "select * from t_proReconRecord where contract_id = 227 and ttr_id = 6 and sell_id = 12");
		for(ProjectReconRecord p : list){
			System.out.println("contract_id = "+p.getContract_id()+", "+
					"ttr_id = "+p.getTtr_id()+", sell_id = "+p.getSell_id()+", config_id = "+p.getConfig_id()+", prr_values = "+p.getPr_values());
		}
	}
}

4. ProReconRecordUtil.java
import java.util.*;
/**对上传的工勘的结果进行处理的工具类*/
public class ProReconRecordUtil
{
	public static void main(String[] args){
		//基站
		int enb_sell_id = 12;
		String enb_prr_value = "pr_en_1=新建机房,pr_en_2=青青小美,pr_en_3=20.0,pr_en_4=30.0,pr_en_6=上走线,"
			+"pr_en_7=一般地区,pr_en_8=20.0,pr_en_9=直流-48V,pr_en_10=室外落地,"
			+"pr_en_12=1.8GHz eRRU3251,pr_en_13=华为,pr_en_14=直流,pr_en_15=抱杆安装,"
			+"pr_en_16=室外,pr_en_17=2.0,pr_en_18=3.0,pr_en_19=1.0,pr_en_20=6.144G-单模-2km,"
			+"pr_en_21=2.0,pr_en_24=单模,pr_en_27=40.0,pr_en_28=2.0,pr_en_34=50.0,pr_en_35=50.0,"
			+"pr_en_36=否,pr_en_37=否,pr_en_50=0度,pr_en_52=抱杆,pr_en_53=是,pr_en_54=40.0,"
			+"pr_en_60=光口,pr_en_61=单模10km,pr_en_63=LC-LC,pr_en_64=单模,pr_en_65=20.0,"
			+"pr_en_69=5.0,pr_en_70=5.0,pr_en_90=10.0,pr_en_91=单相三芯电源线,pr_en_92=10.0"; //实际使用这个地方的值从数据库中获取得到
		int totalPrNumber = 152;
		handPrValue(enb_sell_id, enb_prr_value, totalPrNumber);

		//核心网
		int hardCore_sell_id = 13;
		String hardCore_prr_value = "pr_en_1=是,pr_en_9=1,pr_en_2=2,pr_en_5=2,pr_en_7=一般地区,pr_en_10=3"; //实际使用这个地方的值从数据库中获取得到
		int hardCore_totalPrNumber = 10;
		handPrValue(hardCore_sell_id, hardCore_prr_value, hardCore_totalPrNumber);
	}
	/**对上传的工勘的结果进行处理*/
	public static Map<String, String> handPrValue(int sell_id, String prr_value, int totalPrNumber){
		int[] indexArray = {1,5,9,14,16};
		String[] prArray = prr_value.split(",");
		String[] prName = new String[prArray.length];
		String[] prValue = new String[prArray.length];
		if(prArray.length > 0){
			for(int i = 0; i < prArray.length; i++){
				String[] p_v = prArray[i].split("=");
				prName[i] = p_v[0];
				prValue[i] = p_v[1];
			}
		}
		Map<String,String> map = new LinkedHashMap<String, String>();
		for(int i = 0; i < totalPrNumber; i++){
			boolean flg = false;
			for(int j = 0; j < prName.length; j++){
				if(prName[j].equals("pr_en_"+(i+1))){
					map.put(prName[j],prValue[j]);
					flg = true;
					break;
				}else{
					continue;
				}
			}
			if(!flg){
				map.put("pr_en_"+(i+1),"-10000");
			}
		}
		for(Map.Entry<String,String> obj : map.entrySet()){
			System.out.println(obj.getKey() + " = "+obj.getValue());
		}
		System.out.println("map.size = "+map.size());
		System.out.println("---------------------------------");
		return map;
	}
}
java自定义标签
自定义标签和标签库函数的学习--自己的Demo
自定义表单标签和标签库函数:.tld文件必须放在WEB-INF下
1. viewIpTag.tld
<?xml version="1.0" encoding="UTF-8" ?>  
  
<!-- 这是从 绿色版\apache-tomcat-7.0.42\webapps\examples\WEB-INF\jsp2\jsp2-example-taglib.tld 模板中拷贝过来的 -->  
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"  
    version="2.0">  
    <description>我的自定义标签</description>
    <tlib-version>1.0</tlib-version>
    <short-name>自定义标签</short-name>
    <uri>/thisIsMyTag</uri>
    <tag>
    	<!-- 标签属性的名称 -->
    	<name>colname</name>
    	<tag-class>com.happiness.tag.ShowLocalIP</tag-class>
    	<!-- 有没有标签体,这里empty表示没有,有的话就写jsp -->
    	<body-content>JSP</body-content>
    	<attribute>
    		<description>姓名</description>
    		<name>username</name>
    		<required>false</required>
    		<rtexprvalue>false</rtexprvalue>
    	</attribute>
    	<attribute>
    		<description>性别</description>
    		<name>sex</name>
    		<required>false</required>
    		<rtexprvalue>false</rtexprvalue>
    	</attribute>
    	<attribute>
    		<description>年龄</description>
    		<name>age</name>
    		<required>false</required>
    		<rtexprvalue>false</rtexprvalue>
    	</attribute>
    </tag>
    <function>
    	<description>显示表格行的函数</description>
    	<name>showTableRow</name>
    	<function-class>com.happiness.tag.SelfFunction</function-class>
    	<function-signature>java.lang.String pdType(java.lang.String)</function-signature>
    </function>
</taglib>


2. ShowLocalIP.java
package com.happiness.tag;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.happiness.pojo.StudentPojo;

public class ShowLocalIP extends TagSupport{
	private String username;
	private String sex;
	private Integer age;

	@Override
	public int doStartTag() throws JspException {
		HttpServletRequest request = (HttpServletRequest)this.pageContext.getRequest();
		JspWriter out = this.pageContext.getOut();
//		String ip = request.getRemoteAddr();
//		List<StudentPojo> ss = new ArrayList<StudentPojo>();
//		ss.add(new StudentPojo("张三","男",20));
//		ss.add(new StudentPojo("李四","男",20));
//		ss.add(new StudentPojo("王五","女",20));
//		ss.add(new StudentPojo("刘麻子","女",20));
		
		try{
				out.print("<tr width='50%'>");
				out.print("   <td width='30%'>"+this.username+"</td>");
				out.print("   <td width='30%'>"+this.sex+"</td>");
				out.print("   <td width='30%'>"+this.age+"</td>");
				out.print("</tr>");
		}catch(Exception e){
			throw new RuntimeException(e);
		}
		return super.doStartTag();
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

}


3. SelfFunction.java
package com.happiness.tag;

public class SelfFunction {
	/**方法必须为static类型的*/
	public static String pdType(String ageStr){
		Integer age = null;
		if(ageStr == null || "".equals(ageStr)){
			age = 0;
		}else{
			age = Integer.parseInt(ageStr);
		}
		if(age < 18)
			return "青少年";
		else if(age >= 18 && age < 40)
			return "青年";
		else if(age >= 40 && age < 60)
			return "青壮年";
		else 
			return "老年";
	}
}

4. index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="/thisIsMyTag" prefix="tt"%>  
<html>  
  <head>  
    <title>My JSP 'ELDemo.jsp' starting page</title>  
  </head>  
    
  <body>
    表格如下:  
    <!-- 因为没有标签体,所以直接一个标签就可以了 -->  
    <table>
    	<!-- 自定义标签实现的表格行 -->
    	<tt:colname username="张三" sex="男" age="20"></tt:colname>
    	<tt:colname username="李四" sex="男" age="23"></tt:colname>
    	<tt:colname username="王五" sex="女" age="25"></tt:colname>
    </table>
    <!-- 自定义标签库函数的使用 -->
    	16岁: ${tt:showTableRow("16")}<br />
    	26岁: ${tt:showTableRow("26")}<br />
    	46岁: ${tt:showTableRow("46")}<br />
    	66岁: ${tt:showTableRow("66")}<br />
  </body>  
</html>  

jquery批量文件上传-uploadify
1. upload2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    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" "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>
		<base href="<%=basePath%>">
		<link href="<%=basePath%>uploadify2/uploadify.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="<%=basePath%>uploadify2/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="<%=basePath%>uploadify2/swfobject.js"></script>
		<script type="text/javascript" src="<%=basePath%>uploadify2/jquery.uploadify.v2.1.4.min.js"></script>
	</head>
<body>
<div id="fileQueue"></div>
	<input type="file" name="uploadify" id="uploadify" />
    <p>
        <a href="javascript: jQuery('#uploadify').uploadifyUpload()">开始上传</a> 
		<a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">取消所有上传</a>
	</p>
</body>
<script type="text/javascript">
	//官方网址:http://www.uploadify.com/
	$(document).ready(function(){
		//$("#uploadify").uploadifySettings('scriptData',	{'name':'liudong','age':22});
		$("#uploadify").uploadify({
			'uploader'	:	"<%=basePath%>uploadify2/uploadify.swf",
			'script'    :	"<%=basePath%>/servlet/UploadPhotoServlet",
			'cancelImg' :	"<%=basePath%>uploadify2/cancel.png",
			'folder'	:	"uploads",//上传文件存放的路径,请保持与uploadFile.jsp中PATH的值相同
			'queueId'	:	"fileQueue",
			'queueSizeLimit'	:	10,//限制上传文件的数量
			'fileExt'	:	"*.rar,*.zip,*.png,*.txt",
			//'fileDesc'	:	"RAR *.rar",//限制文件类型
			'auto'		:	false,
			'multi'		:	true,//是否允许多文件上传
			'simUploadLimit':	2,//同时运行上传的进程数量
			'buttonText':	"files",
			//'scriptData':	{'name':'liudong','age':22},//这个参数用于传递用户自己的参数,此时'method' 必须设置为GET, 后台可以用request.getParameter('name')获取名字的值
			'method'	:	"GET"
		});
		
		//$("#uploadify").uploadifySettings();
	});
</script>
</html>

2. UploadPhotoServlet.java
package com.org.servlet;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

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

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import com.db.ReadTxtUtil;


@SuppressWarnings("serial")
public class UploadPhotoServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public UploadPhotoServlet() {
		super();
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out
				.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("  <BODY>");
		out.print("    This is ");
		out.print(this.getClass());
		out.println(", using the GET method");
		out.println("  </BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		String savePath = this.getServletConfig().getServletContext().getRealPath("");
		System.out.print("-----"+savePath);
		savePath = savePath+"/uploads/";
		System.out.println("上传路径:"+savePath);
		File f1 = new File(savePath);
		if(!f1.exists()){
			f1.mkdirs();
		}
		DiskFileItemFactory fac = new DiskFileItemFactory();
		ServletFileUpload upload = new ServletFileUpload(fac);
		upload.setHeaderEncoding("utf-8");
		List fileList = null;
		try {
			fileList = upload.parseRequest(req);
		} catch (FileUploadException e) {
			e.printStackTrace();
		}
		if(fileList==null){
			resp.getWriter().print("No file upload!");
			return;
		}
		Iterator<FileItem> it = fileList.iterator();
		String name = "";
		String extName = "";
		while(it.hasNext()){
			FileItem item = it.next();
			if(!item.isFormField()){//isFormField介绍:true=表单输入 域,false=文件上传域。
				name = item.getName();
				//long size = item.getSize();
				//String type = item.getContentType();
				if(name == null || name.trim().equals("")){
					continue;
				}
				//扩展名格式
				if(name.lastIndexOf(".")>=0){
					extName = name.substring(name.lastIndexOf("."));
				}
				File file = null;
				do{
					//生成文件名
//					name = UUID.randomUUID().toString();
					Date date = new Date();
					DateFormat df = new SimpleDateFormat("yyyyMMddkkmmssSS");
					name = name.substring(0, name.lastIndexOf(".")) + "_"+df.format(date);
					file = new File(savePath+name+extName);
				}while(file.exists());
				File saveFile = new File(savePath+name+extName);
				try {
					item.write(saveFile);
					ReadTxtUtil rtu = new ReadTxtUtil();
					Map<String, String> uploadProReconMap = rtu.readUploadFile(new FileInputStream(saveFile));
					Map<String, String> proReconNameMap = rtu.getProReconNameMap(new BufferedReader(new FileReader(new File("D:\\codefile\\testfile\\PRoReconConstant.txt"))));
					Map<String, String> proReconMap = new LinkedHashMap<String, String>();
					for(Map.Entry<String, String> obj : uploadProReconMap.entrySet()){
						String key = obj.getKey();
						String value = obj.getValue();
						if(proReconNameMap.containsKey(key)){
							proReconMap.put(proReconNameMap.get(key), value);
						}
					}
					System.out.println("*********话说白骨精与孙悟空的恋情-begin");
					for(Map.Entry<String, String> obj : proReconMap.entrySet()){
						System.out.println(obj.getKey()+"="+obj.getValue());
					}
					System.out.println("*********话说白骨精与孙悟空的恋情-end");
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		resp.getWriter().print(name+extName);
		
	}

}

3. ReadTxtUtil.java
package com.db;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

public class ReadTxtUtil {
	public Map<String , String> readUploadFile(FileInputStream fis){
		Map<String, String> map = new LinkedHashMap<String, String>();
		try {
			Workbook wb = WorkbookFactory.create(fis);
			Sheet sheet = wb.getSheetAt(1);
			for(int i = 3; i < sheet.getLastRowNum(); i++){
				Row r = sheet.getRow(i);
				Cell c1 = r.getCell(1);
				Cell c2 = r.getCell(2);
				System.out.println(c1.toString()+"="+c2.toString());
				map.put(c1.toString(), c2.toString());
			}
		} catch (InvalidFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}
	public Map<String,String> getProReconNameMap(BufferedReader br){
		Map<String,String> map = new LinkedHashMap<String, String>();
		try{
			String s = null;
			while((s = br.readLine()) != null){
				if(s.contains("proReconFileName")){
					continue;
				}
				String[] st = s.split("=");
				map.put(st[0].trim(), st[1].trim());
				System.out.println(s);
			}
			br.close();
		}catch(Exception e){
			return null;
		}
		return map;
	} 
	public static void main(String[] args){
		File file = new File("D:\\codefile\\testfile\\PRoReconConstant.txt");
		BufferedReader br = null;
		try {
			br = new BufferedReader(new FileReader(file));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Map<String, String> map = new ReadTxtUtil().getProReconNameMap(br);
		System.out.println(map.size());
	}
}

4. 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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>demo1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
   <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>UploadPhotoServlet</servlet-name>
    <servlet-class>com.org.servlet.UploadPhotoServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>UploadPhotoServlet</servlet-name>
    <url-pattern>/servlet/UploadPhotoServlet</url-pattern>
  </servlet-mapping>
</web-app>
Global site tag (gtag.js) - Google Analytics