问题描述
我已经下载了一个Jquery Image Slider源代码,想要整合我的JSP文件
I have download a Jquery Image Slider source and want to integarte with my JSP File
这是我的Folder Struture
This is my Folder Struture
这是我包括他们的方式
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<link type="text/css" href="/css/jquery.ui.theme.css" rel="stylesheet" />
<link type="text/css" href="/css/jquery.ui.core.css" rel="stylesheet" />
<link type="text/css" href="/css/jquery.ui.slider.css" rel="stylesheet" />
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen"/>
我在服务器控制台中得到这个404
I get this 404 in server console
20:50:04,625 WARN [404_jsp:109] /css/jquery.ui.theme.css
20:50:04,640 WARN [404_jsp:109] /css/jquery.ui.core.css
20:50:04,640 WARN [404_jsp:109] /css/jquery.ui.slider.css
20:50:04,656 WARN [404_jsp:109] /css/style.css
20:50:04,671 WARN [404_jsp:109] /js/cufon-yui.js
20:50:04,671 WARN [404_jsp:109] /js/GreyscaleBasic.font.js
20:50:04,687 WARN [404_jsp:109] /js/jquery.easing.1.3.js
推荐答案
几个问题:
- 如果我在你发布的缩略图中看到了这个问题,你在WEB-INF中有你的css和js文件夹:任何浏览器都不能请求WEB-INF中的任何内容,所以你永远无法获得它。
-
如果您创建docroot / css和docroot / js,您仍然会得到404,因为您无法在/css/style.css上找到文件,但在/your-portlet/css/style.css中 - 在jsps中解决它的一般方法是
- If I see this correctly in that thumbnail image that you posted, you have your css and js folder in WEB-INF: Nothing that's in WEB-INF can be requested by any browser, so you'll never be able to get it.
If you create docroot/css and docroot/js, you will still get 404, because you can't find the files on /css/style.css, but in /your-portlet/css/style.css - the generic way to address it in jsps is
< link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.css"/>
延迟编辑:请求
在portlet的JSP上并不总是有效,因为根据JSP规范,它是一个HttpServletRequest。在门户网站中,这通常与您的portlet的当前路径无关。因此,我建议使用Mark的答案而不是我的答案:liferay-portlet.xml包含与当前portlet相关的文件。从Liferay 7.0开始,您可以使用OSGi-Component等效于liferay-portlet.xml。
Late request
on a portlet's JSP doesn't always work, because according to the JSP specification it's a HttpServletRequest. In the portal world, this is not often relative to the current path of your portlet. Thus, I'd recommend to go with Mark's answer rather than mine: liferay-portlet.xml contains files relative to the current portlet. Since Liferay 7.0, you may use an OSGi-Component's equivalent to liferay-portlet.xml.
这篇关于无法在Liferay Portlet JSP页面中包含css和JS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!