如何将javascript CSS和图像添加到我的spring version 4.3.4项目中 [英] How do I add javascript CSS and images to my spring version 4.3.4 project
问题描述
嗨有人请帮我添加javascript,css图片和其他静态文件到我的jsp页面。我已经尝试了多次并且失败了
我尝试过的事情:
我尝试通过将此行添加到我的jsp文件来添加js
Hi would someone please help me add javascript, css images and other static files to my jsp pages. I have tried severally and defeated
What I have tried:
I have tried adding js by adding this line to my jsp file
<spring:url value="/resources/js/myfunctions.js" var="myfunctions" />
为路径创建一个变量,然后调用这样的路径
to create a varriable for the path and then called the path like this
<script src="${myfunctions}"></script>
然后我编辑了我的调度程序文件并添加了这些行
I have then edited my dispacher file and added these lines
<mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926"/>
<mvc:annotation-driven />
这是我的文件夹结构 Dropbox - Capture.PNG [ ^ ]
推荐答案
{myfunctions}>< / script>
{myfunctions}"></script>
然后我编辑了我的调度程序文件并添加了这些行
I have then edited my dispacher file and added these lines
<mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926"/>
<mvc:annotation-driven />
这是我的文件夹结构 Dropbox - Capture.PNG [ ^ ]
我试图解决它,但特别是有一些问题使用javascript,尽管bein没有工作因此,我已经决定在jsp文件中使用它了。
这是我的jsp文件代码
I have tried to solve it but there are some issues especially with the javascript which is not working despite being loaded, I have therefore settled on having it within the jsp file.
Here is my code for the jsp file
<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core">
<!DOCTYPE html>
<html>
<head>
<spring:url value="" var="myfunctions" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet"href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<title>Home|Welcome</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Merriweather|Roboto|Roboto+Slab" rel="stylesheet">
<link rel="stylesheet" href="<c:url value="/resources/css/style.css" />"></script>
<!-- Bootstrap Date-Picker Plugin -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>
<!-- JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/e00b541afd.js"></script>
<!-- Include jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="<c:url value="/resources/js/myfunctions.js" />"></script>
<!-- Include Date Range Picker -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>
<style>
.affix {
top: 0;
width: 100%;
}
.affix {
padding-top: 70px;
}
</style>
</head>
<body>
<div class="header">
<div class="jumbotron">
<div class="container well">
<canvas id="clock" height="100" width="100" class="clock"> </canvas>
<h1 class="text-center" style="color: #000033; font-family: Merriweather Sans-serif;">
{greeting}< / H1>
< h3 class =text-center>
{greeting} </h1> <h3 class="text-center">
这篇关于如何将javascript CSS和图像添加到我的spring version 4.3.4项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!