java - Spring MVC 配置了静态资源后 @Controller 扫描失效

 露絲瑪麗蓮夢露_533 发布于 2022-10-31 22:18
Spring MVC 配置了静态资源后 @Controller 扫描失效

springMVC-servet.xml中加
后导致 @Controller失效,访问都是 404

springMVC-servet.xml代码:

    
    http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    
        
    
        
            
        
    
    
    
        
            
            
            
        
    
    

applicationContext-Beans.xml代码:

    
    http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
        
        
    
        
            
        
    
        
    
    

项目结构:

1 个回答
  • springMVC-servet.xml 文件中的 <context:annotation-config/> 换成 <mvc:annotation-driven/> 后解决问题。

    2022-11-12 01:43 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有