myeclipse 开发SSH(struts+hibernate+spring)

来源:互联网 发布:国产车遥控编程器 编辑:程序博客网 时间:2024/05/28 09:33

网上有许多相关的文档,参考资料里有详细的说明,这里只是把需注意的地方记录一下:

步骤:struts -----spring ---hibernate

第一步:struts

  1. public ActionForward execute(ActionMapping mapping, ActionForm form,
  2.             HttpServletRequest request, HttpServletResponse response) {
  3.         LoginForm loginForm = (LoginForm) form;// TODO Auto-generated method stub
  4.         if ( username.equals ( "test" ) && password.equals ("test") )        {
  5.                 return mapping.findForward ( "indexForword" );
  6.               } else {
  7.                 return mapping.getInputForward();
  8.               }
  9.     }

第二步:spring

注意:spring选择spring1,applicationContext.xml路径需注意下,在src下改为“/WEB-INF/classes/applicationContext.xml”,在web-inf下为"/WEB-INF/applicationContext.xml"

更改type="org.springframework.web.struts.DelegatingActionProxy"

plug-in放在message-resources下面(struts-config)

如有错误,到myeclipse找spring.jar包copy过去。

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
  3. <struts-config>
  4.   <data-sources />
  5.   <form-beans >
  6.     <form-bean name="loginForm" type="com.dreamity.struts.form.LoginForm" />
  7.   </form-beans>
  8.   <global-exceptions />
  9.   <global-forwards />
  10.   <action-mappings >
  11.     <action
  12.       attribute="loginForm"
  13.       input="/login.jsp"
  14.       name="loginForm"
  15.       path="/login"
  16.       scope="request"
  17.       type="org.springframework.web.struts.DelegatingActionProxy">
  18.       <forward name="failture" path="/login.jsp" />
  19.       <forward name="success" path="/index.jsp" />
  20.     </action>
  21.   </action-mappings>
  22.   <message-resources parameter="com.dreamity.struts.ApplicationResources" />
  23.   <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  24.     <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
  25. </plug-in>
  26. </struts-config>

第三步:hibernate

程序以四层结构来写,结构如附件。

http://p.blog.csdn.net/images/p_blog_csdn_net/bill1315/EntryImages/20081202/截图01.jpg

参考资料:

1,使用myeclipse集成struts,hibernate,spring的一个示例程序   http://www.cnblogs.com/xujiaci/archive/2007/10/11/920597.html

2,MyEclipse开发SSH(Struts+Spring+Hibernate)入门 http://blog.tanggaowei.com/2007/12/myeclipsesshstrutsspringhibernate.html

原创粉丝点击