servlets - jQuery scripts are not downloaded when the index page is opened on context root -
i have web application uses jquery ui. javascripts not downloaded , applied when browse context root directly , rely on welcome file:
but javascripts downloaded , applied when browse welcome file:
my project structure below:
projectname `-- webroot |-- myfiles | `-- index.html `-- web-inf `-- web.xml
in web.xml
, have defined welcome file index.html
uses jquery ui.
<welcome-file-list> <welcome-file>myfiles/index.html</welcome-file> </welcome-file-list>
this can happen if path script source relative current request url, such example
<script src="jquery.js"></script>
when open page by
then attempt download script from
when open page
then attempt download script from
you use domain-relative path instead. assuming file indeed located in
then need declare script source follows
<script src="/projectname/myfiles/jquery.js"></script>
or, dynamic resolving of context path subject changes outside control inside webapp's code
<script src="${pagecontext.request.contextpath}/myfiles/jquery.js"></script>
Comments
Post a Comment