1、在数据库中建立表之后点击完成(Finish) 。点击 finish修改生成的 XML 文件:action-servlet.xml: 最后简单修改一下部分文件(参考代码如下):RegAction.java:package com.dy114.struts.action;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;import org.apache.struts.action.Acti
2、onForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.DynaActionForm;import com.dy114.hibernate.dao.Reg;import com.dy114.hibernate.dao.RegDAO;/*MyEclipseStruts*Creationdate:07-06-2008*XDocletdefinition:*struts.actionpath=“/
3、reg“name=“regForm“scope=“request“*struts.action-forwardname=“success“path=“/success.jsp“*struts.action-forwardname=“failure“path=“/reg.jsp“*/publicclass RegAction extends Action RegDAO regDAO;public RegDAO getRegDAO() returnregDAO;publicvoid setRegDAO( RegDAO regDAO ) this.regDAO = regDAO;/*Methodex
4、ecute*parammapping*paramform*paramrequest*paramresponse*returnActionForward*/public ActionForward execute( ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response ) DynaActionForm regForm = ( DynaActionForm ) form;String username = ( String )regForm.get( “user
5、name“ );String password = ( String )regForm.get( “password“ );Reg reg = new Reg( username, password );regDAO.save( reg );return mapping.findForward( “success“ );index.jsp:reg.jsp:JSP for DynaActionForm formusername : password : success.jsp:successHello,! 最后将项目部署到 MyEclipse 自带的 Tomcat 容器上,开启服务器,之后报错:Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool原因是工具 MyEclipse 在建立 SessionFactory 的时候,少加一个包 commons-pool-1.3.jar ,补上去问题解决