Spring学习笔记 - 第006天

Spring+hibernate+struts2

配置applicationContext.xml


    
    
    
    
    
    
    
    

    
    
        
        
        
        
        
        
        
    

    
    
        
        
        
        
            
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.show_sql=true
                hibernate.format_sql=true
            
        
    
    
    
    
        
    

    
    


配置struts.xml




    
     
    
        
            /WEB-INF/jsp/index.jsp
        
    
 

配置web.xml


    
    
    
        contextConfigLocation
        classpath:app.xml
    
 
    
    
        struts2
        
            org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
        
    
 
    
        struts2
        /*
    
 
    
    
        index.action
    
 
    
    
        
            org.springframework.web.context.ContextLoaderListener
        
    

struts2 action例子
@Controller("index")
@Scope("prototype")
public class IndexAction {  
    @Autowired
    private BookService bookService;
    
    private List bookTypes;
    
    public List getBookTypes() {
        return bookTypes;
    }
    
    public String execute() {
        bookTypes = bookService.getAllBookType();
        return "success";
    }
}

struts2默认首页

struts2路径随便输入调到指定页面
    
            index
        
    

你可能感兴趣的:(Spring学习笔记 - 第006天)