I have written spring mvc project I have written following in my context.xml to locate resources
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:resources mapping="/resources/**" location="/resources/js/" />
also I tried
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:resources mapping="/resources/js/**" location="/resources/js/" />
Following is my html file.
<html>
<head>
<meta charset="UTF-8">
<title>Home Page</title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<script type="text/javascript" src="/resources/js/studentApp.js"></script>
</head>
<body></body></html>
Following is a directory structure
In javascript console it shows,
GET //localhost:8080/resources/js/studentApp.js 400 (Bad Request)
Why it is not loading/not found studentApp.js? Please make correct if I am wrong :)
Thank you.
You are not entering the correct path name. Just include project name in path.
<script type="text/javascript" src="--YOUR PROJECT NAME--/resources/js/studentApp.js"></script>
or refer to a path relative to the current directory while loading (ie: use a relative path ). This is done by inserting "./ "
.
<script type="text/javascript" src="./resources/js/studentApp.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.