0

CSS and JS Files are not loading in my application, below is the project structure and header part.

    <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<script type='text/javascript' src='js/jquery-1.2.3.min.js'></script>
<script type='text/javascript' src='js/menu.js'></script>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />

</head>

enter image description here

Please help me with this.

Shaik khaja Hussain
  • 335
  • 1
  • 4
  • 16

1 Answers1

0

You have to add the relative path for the css and js files. I will mention a sample for your css files, follow the same for js files also.

<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" />

Or you can copy your css and js folders in to the web-inf folder and use the following reference code,

<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
Dinidu Hewage
  • 2,169
  • 6
  • 40
  • 51
  • It is not helping me, I have made the changes as you said, when i view the source code and click on "../../js/jquery-1.2.3.min.js", it shows 404 url "http://localhost:8080/js/jquery-1.2.3.min.js". – Shaik khaja Hussain Jan 04 '16 at 06:37
  • Then use the second answer without changing the folder locations. – Dinidu Hewage Jan 04 '16 at 06:41
  • now the URL shows "http://localhost:8080/SpringSecurity/js/jquery-1.2.3.min.js", but still a 404 error. This URL should be fine, But I don't understand why it is not loading !! – Shaik khaja Hussain Jan 04 '16 at 06:55
  • Hi Dinidu, I'm using spring security and Spring tiles concepts in this application does it make any difference in accessing css and js files ? – Shaik khaja Hussain Jan 04 '16 at 07:08
  • Check your build folder and see the hierarchy of folder. Then you will be able to figure out the relative path – Dinidu Hewage Jan 04 '16 at 08:03