gpt4 book ai didi

jquery - Spring Mvc jsp页面在使用js和css文件初始化日历后给出空白输出

转载 作者:太空宇宙 更新时间:2023-11-04 14:58:07 24 4
gpt4 key购买 nike

我不确定为什么在尝试使用以下文档初始化日历时从 jsp 文件中得到空白输出。我想我已经正确地遵循了这个网站上的文档:http://arshaw.com/fullcalendar/ .我已将代码附加到我的 jsp 文件和我下载到 WEB-INF 文件夹中的文件 View 。请参阅下面的图片说明。感谢您的帮助!

enter image description here

最佳答案

日历div 选择器不正确。将其从 $('calendar') 更改为 $('#calendar')

评论后编辑

另外,关于JS、CSS、图片文件等静态资源的部署:这些资源必须放在WEB-INF目录之外。它们可以放在应用程序根目录中的任何目录结构中,WEB-INF 中除外。这就是Servlet 3 specification说。以下是摘录。

A special directory exists within the application hierarchy named “WEB-INF”. This directory contains all things related to the application that aren’t in the document root of the application. Most of the WEB-INF node is not part of the public document tree of the application. Except for static resources and JSPs packaged in the METAINF/ resources of a JAR file that resides in the WEB-INF/lib directory, no other files contained in the WEB-INF directory may be served directly to a client by the container.

您可以在规范的“第 10.5 节:目录结构”中找到更多详细信息。

因此,如果您确实想将静态资源放在 WEB-INF 中,则需要将它们打包到驻留在 WEB 中的 JAR 文件的 METAINF/resources 中INF/lib.

假设您的应用程序的上下文路径(以及您的应用程序在部署中的根目录的名称)是context。现在假设您在该根目录中创建目录层次结构 scripts/jquery,并将 jquery.min.js 放入该目录中。现在,要在您的 JSP 中包含 jquery.min.js,您可以指定以下内容:

<script src="/context/scripts/jquery/jquery.min.js"></script>

要使其在 spring 应用程序中工作,您需要将以下内容放入 spring 配置中。

<mvc:default-servlet-handler />

这将允许您的应用程序容器本身处理对静态资源的请求。查看documentation了解更多详情。

关于jquery - Spring Mvc jsp页面在使用js和css文件初始化日历后给出空白输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16773722/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com