SSM整合报404 RequestMapper不起作用

前言

提示:当报404可以在Controller方法里加一个System.out.println(“XXXX”);

判断你的映射是否有效


下面案例可供参考

如果控制台没有输出说明没起效
如果控制台没有打印,那么确定是Mapping参数没有作用

检查步骤

1.applicationContext和SpringMVC的配置文件

查看头文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">

1.1组件扫描器component-scan的错误检查

在输入<component-scan会提示
键入

<!--    组件扫描器-->
    <context:component-scan base-package="com.XXX.XXX"/>

顶部头文件应该是补充了
在这里插入图片描述

xmlns:context="http://www.springframework.org/schema/context"

1.2 注解驱动annotation-driven的检查

在输入<driven会提示
记得选择的是末尾是MVC的选项
在这里插入图片描述

顶部头文件应该是补充了

xmlns:mvc="http://www.springframework.org/schema/mvc"

总结

在检查了域名和参数绑定检查,大多是配置文件的问题,检查时发现引错了,需要去掉,再键入引入正确的头文件

个人的一些bug解决,希望能帮到大家

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值