posts - 325,  comments - 25,  trackbacks - 0
1.注意在加载完hiberna包之后,放入以下三个jar包:spring.jar commons-collection-3.2.jar,commons-pool-1.3.jar,删除两个包由于cglib-2.1.3,(cglib-2.1.3 依赖的asm 跟在外边的asm版本不一致导致, 把cglib换成 cglib-nodep版本的就可以了),asm-2.2.3.jar
2.从数据库映射完vo之后,注意一对多,多对多等的配置
       一对多: 如:“一”这方ExamType.hbm.xml 添加
        <set name="questions" inverse="true"> //“一”这方没有控制权
             <key column="typeid"></key>
             <one-to-many class="com.lhb.onlineexam.vo.Question"/>
          </set>
                
            “多”这方Question.hbm.xml 添加
                <many-to-one name="examtype" column="typeid" not-null="true" lazy="false" insert="false"></many-to-one>
            “多”这方有控制权

     多对多:
        如course.hbm.xml 
        <set name="student" table="student_course" cascade="save-update"
         inverse="true">
             <key column="cou_id"></key>
             <many-to-many column="stu_id"
              class="com.lhb.first.vo.Student">
             </many-to-many>
        </set>

        student.hbm.xml
        
            <set name="course" cascade="save-update" inverse="false"  //因为是学生选课,不是课先学生,所以有控制权
               table="student-course">
                   <key column="stu_id"></key>
                   <many-to-many column="cou_id"
                    class="com.lhb.first.vo.Course">
                   </many-to-many>
              </set>

    3.   web.xml中的配置
    加入:
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
 </context-param>
 <servlet>
  <servlet-name>SpringContextServlet</servlet-name>
  <servlet-class>
   org.springframework.web.context.ContextLoaderServlet
  </servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <filter>
  <filter-name>requestContextFilter</filter-name>
  <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>requestContextFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter>
  <filter-name>encodingFilter</filter-name>
  <filter-class>
   org.springframework.web.filter.CharacterEncodingFilter
  </filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>   

4.在完成模型组件和业务逻辑组件之后,配置applicationContext.xml(注入bean)
5.加入struts支持,配置struts-config.xml
    <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
  </plug-in> 
    如果使用spring的DelegatingRequestProcessor(此时可以没有type属性),则在struts-config.xml中加入
    <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
    如果使用spring的DelegatingActionProxy(此时type都是type="org.springframework.web.struts.DelegatingActionProxy")
    struts-config.xml中什么也不加
        
posted on 2008-05-15 15:56 长春语林科技 阅读(151) 评论(0)  编辑  收藏 所属分类: util

只有注册用户登录后才能发表评论。


网站导航:
 
<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜