最近正在学习webwork,现在把其中的几个配置文件整理一下。看了很多的视屏。都遇到同样的问题。整理的4天终于弄明白了。重要的是去spring的官方下载最新的spring软件包。我用的是myeclipse6.5 tomcat6.0 jdk 1.6
xwork.xml
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
"http://www.opensymphony.com/xwork/xwork-1.0.dtd">
<xwork>
<include file="webwork-default.xml"></include>
<package name="default" extends="webwork-default">
<action name="register" class="org.cx.webwork.action.UserAction" method="register">
<result name="success">register_success.jsp</result>
</action>
</package>
</xwork>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 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-app_2_4.xsd">
<filter>
<filter-name>webwork</filter-name>
<filter-class>
com.opensymphony.webwork.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>webwork</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>register.jsp</welcome-file>
</welcome-file-list>
</web-app>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/bookshop">
</property>
<property name="username" value="root"></property>
<property name="password" value="bjnms31"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/cx/webwork/vo/Orders.hbm.xml</value>
<value>org/cx/webwork/vo/Catalog.hbm.xml</value>
<value>org/cx/webwork/vo/User.hbm.xml</value>
<value>org/cx/webwork/vo/Orderitm.hbm.xml</value>
<value>org/cx/webwork/vo/Book.hbm.xml</value>
</list>
</property>
</bean>
<bean id="baseDAO" class="org.cx.webwork.dao.BaseDAO"
abstract="true">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userDAO" class="org.cx.webwork.dao.impl.UserDAO"
parent="baseDAO">
</bean>
<bean id="userService"
class="org.cx.webwork.service.impl.UserService">
<property name="userDAO">
<ref bean="userDAO" />
</property>
</bean>
<bean id="userAction" class="org.cx.webwork.action.UserAction">
<property name="userService">
<ref bean="userService" />
</property>
</bean>
</beans>
xwork.xml
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
"http://www.opensymphony.com/xwork/xwork-1.0.dtd">
<xwork>
<include file="webwork-default.xml"></include>
<package name="default" extends="webwork-default">
<action name="register" class="org.cx.webwork.action.UserAction" method="register">
<result name="success">register_success.jsp</result>
</action>
</package>
</xwork>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 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-app_2_4.xsd">
<filter>
<filter-name>webwork</filter-name>
<filter-class>
com.opensymphony.webwork.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>webwork</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>register.jsp</welcome-file>
</welcome-file-list>
</web-app>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/bookshop">
</property>
<property name="username" value="root"></property>
<property name="password" value="bjnms31"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/cx/webwork/vo/Orders.hbm.xml</value>
<value>org/cx/webwork/vo/Catalog.hbm.xml</value>
<value>org/cx/webwork/vo/User.hbm.xml</value>
<value>org/cx/webwork/vo/Orderitm.hbm.xml</value>
<value>org/cx/webwork/vo/Book.hbm.xml</value>
</list>
</property>
</bean>
<bean id="baseDAO" class="org.cx.webwork.dao.BaseDAO"
abstract="true">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userDAO" class="org.cx.webwork.dao.impl.UserDAO"
parent="baseDAO">
</bean>
<bean id="userService"
class="org.cx.webwork.service.impl.UserService">
<property name="userDAO">
<ref bean="userDAO" />
</property>
</bean>
<bean id="userAction" class="org.cx.webwork.action.UserAction">
<property name="userService">
<ref bean="userService" />
</property>
</bean>
</beans>