实训周ssh框架的一些体会和配置文件

两周的实训周。做一个图书管理的网站。有用户管理,图书管理,图片管理,评论管理的功能。底层代码方法实现就是对数据库的增删查改,通过这些方法的测试个人分类管理。

配置:MyEclipse8.5   hibernate3.3     jdk1.6 (发现jdk1.8和框架不兼容)  struts架包基本都是2.1.6版本的,只要不重复就不会有冲突。

错误:不能加载spring配置文件。web.xml   spring路径后加*

重新加载项目,删除缓存。每次修改完spring配置文件后都要再重启一下tomcat服务器,如果代码没问题还总是有错误,就要重启软件了。spring配置文件里要定义hibernate的配置文件的路径,还有事务管理器,定义规则,定义哪些方法使用这些规则。错误:不能加载spring配置文件。web.xml   spring路径后加*

 

不能加载spring配置文件,一定是文件没写正确,或者hibernate路径删除了。实体类不能映射,方法没有成功,hql语句可能写错了,把各个类的映射文件xml数据库名删掉一下。设置lazy=false可以延时加载,提高效率。

重新加载项目,删除缓存。每次修改完spring配置文件后都要再重启一下tomcat服务器,如果代码没问题还总是有错误,就要重启软件了。spring配置文件里要定义hibernate的配置文件的路径,还有事务管理器,定义规则,定义哪些方法使用这些规则。

 

 

贴一下自己的项目的几个配置文件仅供参考。


    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"

  xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        
        ">


             class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        
        

    

    
             class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        
    

 

    
    
        
        
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
        

    

    
        
                     expression="execution (* demo.service.impl.*.*(..))" />
        
    

    
    


    
        
    

    
        
        
    

    
        
    

 

    

    
        
    


    
        
        
    

    
        
        
    

    
        
    


    
        
    

    
        
    

 

    

 

web.xml文件


    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    
        Spring character encoding filter
        org.springframework.web.filter.CharacterEncodingFilter
        
            encoding
            UTF-8
        

        
            forceEncoding
            true
        

    

    

    
        contextConfigLocation
        classpath:applicationContext.xml
    

    
        Spring character encoding filter
        /*
    

    
    
        struts2
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    

    
        struts2
        /*
    

    
    
        DwrServlet
        org.directwebremoting.servlet.DwrServlet
        
            debug
            true
        

    

    
        DwrServlet
        /dwr/*
    

    
    
        org.springframework.web.context.ContextLoaderListener
    

    
        index.jsp
    

    
        BASIC
    

struts文件:




    
    

    
    


    
        
            findAllBook
        

        
            /add_book.jsp
        

        
            findAllBook
        

        
            /manager.jsp
        

        
            /firstPage.jsp
        

        
            /book.jsp
        

    

    
        
            /manager.jsp
        

        
            findAllUsers
        

        
            findAllBooks
        

        
            /addmanager.jsp
        

        
            findAllUsers
        

        
            findAllBooks
            /fail.jsp
        

        
            /success.jsp
            /fail.jsp
        

        
            /manager.jsp
        

        
            /firstPage.jsp
        

    


    
        
            
                rows
            

        

        
            
                rows
            

        

        
            
                rows
            

        

    

    
        
            
                row
             

        

        
            
                row
             

        


        
            
                row
            

        


        
            
                row
            

        

    



这几个文件在网上是有现成的,拷过来改改符合自己的项目条件就好了。

 

 

 

 

 

你可能感兴趣的:(实训周ssh框架的一些体会和配置文件)