jsf 2 - javascript file not loading -
trying import js file page.
my page in webcontent/mydomain/templates/page.xhtml
my js in webcontent/mydomain/test/scripts
in page.xhtml
<script type="text/javascript" src="../test/scripts/test.js"></script>
but still script not getting picked.
can tell how need give path in src.
provided webcontent
root of public web content , /mydomain
public folder , javascript standalone available http://localhost:8080/context/mydomain/test/scripts/test.js
, assuming domain of http://localhost:8080
, context path of /context
, following should do:
<script src="#{request.contextpath}/mydomain/test/scripts/test.js"></script>
this generate domain-relative url dynamically inlined context path, more robust fiddling ../
make uri relative current request uri (as see in browser's address bar) , not physical location of template file many starters incorrectly assume.
Comments
Post a Comment