Tomcat無法載入css和js等靜態資源檔案的解決思路_Linux

來源:互聯網
上載者:User
解決思路有兩個

一是,你使用了Apache伺服器,html不交給Tomcat處理,所以你找不到Html等靜態資源,所以你先停掉阿帕奇,然後只用Tomcat貓試試。
二是,像我一樣,使用了Jetty開發程式,但是打war包的時候忘記幹掉web.xml中的jetty修改靜態資源的代碼。如下,幹掉即可。
複製代碼 代碼如下:

<servlet>
<servlet-name>default</servlet-name>
<!-- <servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class> -->
<servlet-class>
org.eclipse.jetty.servlet.DefaultServlet
</servlet-class>
<init-param>
<param-name>useFileMappedBuffer</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

沒有幹掉這一段之前,樣子是這樣的噁心:

幹掉了jetty配置之後,就變成了下面這種,哈哈!!
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.