SSM整合报404
前言
提示:当报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解决,希望能帮到大家