0
点赞
收藏
分享

微信扫一扫

springMVC学习笔记-静态资源加载失败 Failed to load resource: the server responded with a status of 404()

路西法阁下 2022-04-24 阅读 61
springmvc

今天练习一个spring的小demo,跟着视频练习,搭建好环境后,打算用给的代码基础上,添加功能,但是打开时候,页面是乱的,图片都没加载出来,如下图:
在这里插入图片描述

之后点击F12,查看到是有些资源没有加载出来,Failed to load resource: the server responded with a status of 404()
在这里插入图片描述

自己尝试写一下测试的aaa.jsp页面,简单写了一个{pageContext.request.contextPath},但是解析不出来的,会直接把这个打印到页面上
在这里插入图片描述在这里插入图片描述
最终在网上找到了解决办法,需要修改web.xml的版本,我之前的代码是没有版本的
在这里插入图片描述
进行修改,修改为

<web-app version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

如下图:
在这里插入图片描述

修改之后,aaa.jsp页面是空白的,这是正常的
在这里插入图片描述

主页面恢复正常:
在这里插入图片描述

参考博客:https://blog.csdn.net/qq_41413743/article/details/121028638

举报

相关推荐

0 条评论