上面示例的代码已基本完成。现在这开始编写配置文件了。主要有beanx.xml,struts.xml,web.xml这几个文件 。
1.beans.xml【spring核心配置文件】
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 配置session工厂 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- annotation风格的声明式事务管理 -->
<tx:annotation-driven transaction-manager="txManager" proxy-target-class="true" />
<bean id="JbpmConfiguration"
class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
<property name="configuration" value="classpath:jbpm.cfg.xml" />
<property name="createSchema" value="false" />
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- jBPM template -->
<bean id="JbpmTemplate"
class="org.springmodules.workflow.jbpm31.JbpmTemplate">
<constructor-arg index="0" ref="JbpmConfiguration" />
</bean>
<!-- 配置jbpmdao -->
<bean id="monthJbpmDao" class="org.qhit.jbpm.MonthDao">
<property name="template">
<ref local="JbpmTemplate"/>
</property>
</bean>
<!-- 配置业务类 -->
<bean id="monthBiz" class="org.qhit.jbpm.biz.MonthJbpmBiz">
<property name="monthDao">
<ref local="monthJbpmDao"/>
</property>
</bean>
<!-- 配置actions -->
<bean id="monthAction" class="org.qhit.web.actions.MonthAction">
<property name="monthJbpmBiz">
<ref bean="monthBiz"/>
</property>
</bean>
</beans>
2.struts.xml文件【struts2配置文件】
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml" />
<constant name="struts.multipart.saveDir" value="c:\tmp"></constant>
<constant name="struts.multipart.maxSize" value="4097152"></constant>
<package name="struts-default-self" extends="struts-default">
<global-results>
<result name="error">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="error"
exception="java.lang.Exception">
</exception-mapping>
</global-exception-mappings>
<action name="month" class="monthAction">
<result name="ok">/ok.jsp</result>
</action>
</package>
</struts>
这里比较简单,仅仅配置org.qhit.web.actions.MonthAction这个控制类。
3.web.xml【web核心配置文件】
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean*.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>ProcessImageServlet</servlet-name>
<servlet-class>
org.jbpm.webapp.servlet.ProcessImageServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ProcessImageServlet</servlet-name>
<url-pattern>/processimage</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
配置完毕!接下来的工作便是测试了,这个工作也很重要。休息下先...