JSP doesn't see CSS

后端 未结 1 1521
悲&欢浪女
悲&欢浪女 2021-01-24 11:08

I\'m trying to make a simple Servlets + JSP project. It\'s structure looks like this:

\"enter

1条回答
  •  孤独总比滥情好
    2021-01-24 11:35

    There are two problems in your app:

    1. In JSP, you should use ${pageContext.request.contextPath} to append the base path for your URLs. With this, you can be sure you will use absolute path instead of relative path for your URLs. So, this:

      
      

      Will be

      
      

      This can also be accomplished by using from JSTL:

      
      
    2. Your servlet is mapping to every request made in your app. Note that this includes simple requests for resources like this CSS file. If you're not handling these requests successfully, you may get an error response or an empty response or whatever, depends on how you handle the request for CSS files in the servlet. I recommend you to change the URL pattern for your servlet to map to specific paths instead.

      
          IndexServlet
          /index
      
      

    0 讨论(0)
提交回复
热议问题