Browser can't access/find relative resources like CSS, images and links when calling a Servlet which forwards to a JSP

前端 未结 9 1335
小蘑菇
小蘑菇 2020-11-21 05:43

I\'m having trouble with loading CSS and images and creating links to other pages when I have a servlet forward to a JSP. Specifically, when I set my

9条回答
  •  野的像风
    2020-11-21 06:12

    As for your update, I was confused for the reasoning behind in. Dug a little deeper and found this gem:

    • yoursite.com becomes yoursite.com/
    • yoursite.com/ is a directory, so the welcome-file-list is scanned
    • yoursite.com/CMS is the first welcome-file ("CMS" in the welcome-file-list), and there is a mapping of /CMS to the MyCMS servlet, so that servlet is accessed.

    Source: http://wiki.metawerx.net/wiki/HowToUseAServletAsYourMainWebPage

    So, the mapping then does make sense.

    And one can now freely use ${pageContext.request.contextPath}/path/ as src/href for relative links!

提交回复
热议问题