Could someone explain why absolute paths not recommended to use in JSP (e.g., IntelliJ IDEA show me a warning)?
答案网址:https://stackoverflow.com/questions/15759549/jsp-absolute-paths
| |||||||||||||
|
Consider the following code in your JSP:
And you deploy your application on
However, the browser will not find the script. The URL where it can actually be found containts the servlet context as well as part of the URL:
So you should change the URL in your JSP to:
Then the context path is also available in the URL and everything will work fine. | |||||||||||||||||||||
|