No mapping found for HTTP request with URI

参考: 参考地址

说明

ssm老项目,接过来别人的项目

临时建了一个Controller方便测试用的,结果访问掉不通,报: No mapping found for HTTP request with URIxxxx 这样的错误

解决办法

看了下web,xml配置

在 webmvc-config.xml 配置文件里面添加了几行配置

说明: com.iph.hiring.headcount.api.service.* 是我Controller所在的地址,

酷酷一顿乱粘, 重启项目,发现好使了.

xml 复制代码
    <context:annotation-config/>
    <context:component-scan base-package="com.iph.hiring.headcount.api.service.*"
                            use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        <context:include-filter type="annotation" expression="org.springframework.context.annotation.Configuration"/>
        <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController"/>
    </context:component-scan>
    <mvc:annotation-driven/>
    <mvc:default-servlet-handler/>
    <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

启动项目观察控制台

发现有这个url地址了

然后用postman调用, 也能调用通过了.

相关推荐
程序员黑豆7 小时前
Java类型推断完全指南:从var到菱形运算符,掌握使用限制与最佳实践
java·前端·ai编程
风流 少年8 小时前
Spring AI 2.0:Memory
java·后端·spring
码匠许师傅8 小时前
【C++ 面试真题】聊聊 C++ 的移动语义与右值引用
java·c++·面试
小席是个热心肠9 小时前
AI相关的自我学习
java·人工智能·学习
Java成神之路-11 小时前
Spring Cloud 微服务契约先行:为什么 Controller 建议要实现 Feign 接口?
spring·spring cloud·微服务
数智化管理手记11 小时前
海量数据如何沉淀有效数据资产?数据标准化治理方案如何搭建?
java·大数据·人工智能
cfm_291412 小时前
SpringAI + Ollama 本地大模型
java·开发语言·人工智能·语言模型
鲸采云SRM采购管理系统13 小时前
采购管理系统哪家好?2026最新测评对比
java·服务器·数据库
0x5313 小时前
Java网络编程(二)
java·服务器·网络
Flittly14 小时前
【雕虫大技】Agent 动态 Skill 供应链安全加固(三):输出校验与治理闭环实战
java·spring boot·spring