MyEclipse6.0.1中SSH項目的配置

一加入SSH支持

1、加入spring2.0的支持
加入的包有:
            Spring2.0 AOP Libraries(對aop的支持)
            Spring2.0 Core Libraries
            Spring2.0 Persistence Core Libraries
            Spring2.0 Persistence JDBC Libraries(JDBC支持)
            Spring2.0 Testing Suppor Libraries
            Spring2.0 Web Libraries
            Hibernate3.2 Core Libraries
            Hibernate3.2 Annotations & Entity Manager
            Hibernate3.2 Advanced Support Libraries
2、加入hibernate 選擇myEclipse Libraries 但是不選擇任務包

3、加入struts1.2的支持

二正確配置配置文件

1、Spring 配置文件配置如下:

MyEclipse6.0.1中SSH項目的配置Code
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        
<property name="sessionFactory">
        
<ref bean="sessionFactory"/>
        
</property>
        
</bean>
        
<bean id="persondao" class="com.ssh.impel.PersonDAOImpel">
        
<property name="hibernateTemplate">
        
<ref bean="hibernateTemplate"/>
        
</property>
        
        
</bean>
        
<bean name="/pserson" class="com.ssh.struts.action.PsersonAction">
        
<property name="persondao">
        
<ref bean="persondao"/>
        
</property>
        
</bean>

2、struts配置文件配置如下:

 

 

3、web-xml配置文件配置如下:

 <context-param>
  
<param-name>contextConfigLocation</param-name>
  
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
  
</context-param>
  
<servlet>
  
  
<servlet-name>context</servlet-name>
  
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
  
<load-on-startup>1</load-on-startup>
  
</servlet>

 

4、加入包commons-pool.jar spring.jar
5、刪除包asm-2.2.3.jar hibernate-annotaions.jar

這裏只粘貼了需要手動配置的代碼。

最後總結一下配置ssh 環境的需要步驟

1、加入spring 包(增刪一些衝突包)

2、加入hibernate包

3、加入struts包

4、在applicationContext.xml文件註冊“hibernateTemplate” bean

5、在struts-config.xml中加入插件“ContextLoaderPlugIn”

6、在struts-config.xml文件中配置<controller>節點

7、在web.xml中註冊struts

之後就按項目需要來做了

建一個表就建一個pojo,然後生產hibernate配置文件

建一個dao 就在spring 裏面註冊一下  建一個impel 也在spring 裏註冊一下

建一個action 就在spring裏註冊一下

加入驗證框架,配置validation-xml ,然後在ApplicationResource.properties配置錯誤信息

加上validate=true

加入插件ValidatorPlugIn

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章