java 配置静态资源_SpringMVC如何正确配置静态资源(css,js,images)?

本文探讨了Spring MVC框架中配置DispatcherServlet时遇到的问题,包括页面出现404错误及CSS、JS等静态资源无法加载的情况。作者尝试通过调整配置解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

WEB.XML

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"

version="2.5">

qiye

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

/WEB-INF/qiye-servlet.xml

1

qiye

/

qiye-servlet.xml

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

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

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

xsi:schemaLocation="

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

http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd">

我加上了

但是页面报404错误.

如果去掉 SpringMVC视图就正常.但是css文件,js文件,图片加载不出来.

http://127.0.0.1:28080/Qiye/j...

我这这样访问的 ,有错吗?

d9bf0e8e79bc61ef6f077cdf3ea34724.png

home文件夹下都是前端html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值