In Javaweb development, JavaScript and CSS files are often introduced using absolute paths, which avoids the fact that the directory changes lead to the introduction of files that are not found, and are commonly used as follows:
Use ${pagecontext.request.contextpath}
The role of the Code "${pagecontext.request.contextpath}" is to remove the deployed application name so that no matter how it is deployed, the path used is correct!
EX:
<!--using absolute paths to introduce CSS files--><link rel= "stylesheet" href= "${pagecontext.request.contextpath}/demo/default/css /index.css " type=" text/css "/><!--using absolute paths to introduce JavaScript scripts--><script type=" Text/javascript "src=" ${ Pagecontext.request.contextpath}/demo/js/index.js "></script>
Use <%=request.getcontextpath ()%> and use ${pagecontext.request.contextpath} to achieve the same effect
<script type= "Text/javascript" src= "<%=request.getcontextpath ()%>/demo/js/index.js" >
<script>
JSP obtains absolute path