0
点赞
收藏
分享

微信扫一扫

SpringMVC 406状态码

邯唐情感 2022-04-26 阅读 106
spring

错误状态:

浏览器:

 服务器正常,经过排查发现是添加注解驱动时添加成了第一项alibaba的

解决方法:

将错误的注解驱动删除,换成下面这个:

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

修改后的配置文件如下:springmvc.xml

<?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:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!--添加包扫描-->
    <context:component-scan base-package="cn.hust.controller"></context:component-scan>
    <!--添加注解驱动-->
    <mvc:annotation-driven></mvc:annotation-driven>
</beans>

注意:

删除错误的注解驱动后一定要将文件头部xmlns以及xsi区域变灰的部分完全删除,再添加新的才奏效

举报

相关推荐

0 条评论