Cannot access CSS files defined under WEB-INF from JSP(无法从 JSP 访问在 WEB-INF 下定义的 CSS 文件)
问题描述
我已经使用 Maven 创建了 Struts2 应用程序.在这个应用程序中,我创建了两个命名空间,第一个是 tc
,第二个是 cmpui
.从 JSP 页面,我试图访问 .css
文件,但它给了我 404 错误.
I have created Struts2 application using Maven. In this application I have created two namespaces, first is tc
and the second one is cmpui
. From the JSP page, I am trying to access .css
files, but it is giving me 404 error.
JSP 页面的位置是:
Location of JSP page is :
webapp clayoutstylesheets.jsp
CSS 文件的位置是:
Location of CSS file is :
WEB-INFcssdefault.css
JSP 页面上的代码是
Code on JSP page is
<link rel="stylesheet" type="text/css" href="../WEB-INF/css/default.css">
请给点建议.
推荐答案
您无法访问 WEB-INF
文件夹下的资源.将您的静态资源移动到 Struts2 可访问的另一个位置(例如,Web 根目录).并使用 s:url
标签构建 URL.
You can not access a resources that are under WEB-INF
folder. Move your static resources to another place accessible by Struts2 (for example, web root). And use s:url
tag to build the URL.
<link rel="stylesheet" type="text/css" href="<s:url value='/css/default.css'/>">
这篇关于无法从 JSP 访问在 WEB-INF 下定义的 CSS 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法从 JSP 访问在 WEB-INF 下定义的 CSS 文件


基础教程推荐
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01