I have some path problems, and I can't resolve them, I searched over
and over again and still not working, I get a 404 (Not Found) for
.../CpdApplication/Chart.js
Indeed, when writing <script src="/Chart.js"/>
you are telling the browser to make its own, separate HTTP request to get the JavaScript file. For this to work:
- The servlet container needs to be able to serve static files
- To this end, you need to have a servlet-mapping inside your web.xml to serve static files (ie. the default servlet).
This should do:
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/js/*</url-pattern>
</servlet-mapping>
Then place your Chart.js
in the following folder: WebContent/js/
and it should work.
EDIT: Of course, you'll need to update the <script>
tag in your HTML. Also, make sure that you redeploy your web app to update web.xml on your servlet container (Tomcat I presume).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…