Can't serve static index.html with Spring Boot


I'm new to Spring and I find it is really hard to get into it. I want to serve a static index.html but it doesn't work. <a href="https://i.stack.imgur.com/9mlc0.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/9mlc0.png" data-original="https://i.stack.imgur.com/9mlc0.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

I used <a href="https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot" rel="nofollow">this</a> tutorial but can't access index.html with: <a href="http://localhost:8080/" rel="nofollow">http://localhost:8080/</a> or <a href="http://localhost:8080/src/main/public/index.html" rel="nofollow">http://localhost:8080/src/main/public/index.html</a>


package de.phip1611.springboot_test_1; import org.springframework.stereotype.Controller; @Controller public class IndexHtmlController {} // due to https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot // this should be enough..

<a href="https://i.stack.imgur.com/swhBt.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/swhBt.png" data-original="https://i.stack.imgur.com/swhBt.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>


Can you try the below:

<ol><li>Move index.html to src/main/resources/static folder</li> <li>In the application.properties file of spring boot, set server.contextPath to /. (i.e. server.contextPath=/)</li> </ol>


I have a html file in src/main/resources/static folder and added below in application.yml but it didn't work for me either. On tomcat start ,localhost:8080 shows a 404 and webpage shows whitelabel error. But for localhost:8080/hello.html I see a 200 response code when inspect but no contents of html on webpage .

server: servlet: context-path: / port: 8080


  • Some fields not getting parsed/deserialized in JSON in Springboot
  • Glassfish doesn't bring up EntityManager if DAO is not Stateless
  • Springboot Whitelabel Error Page
  • Rendering a google line chart, curveType not setting and animation not working as expected
  • Playing a monetized YouTube song inside of a Google Chrome Extension. Do I have any options?
  • Controlling Prolog variable value selection
  • Insert null in a database
  • Device still has the old apk
  • Spring @Transactional - javax.persistence.TransactionRequiredException
  • wxPython: binding wx.EVT_CHAR_HOOK disables TextCtrl backspace
  • jQuery datepicker with Spring MVC - Passing date from view to controller sends null
  • Gitlab - Google compute engine Continuous delivery
  • Can't access Facebook campaigns
  • How to get the sql state from libpq?
  • No rows to manipulate in html table created with jQuery csvToTable?
  • why 0.1+0.2-0.3= 5.5511151231258E-17 in php [duplicate]
  • android duplicate provider authority on apps that don't have provider
  • Automapper missing type map configuration or unsupported mapping
  • unrecognized selector isPitched called
  • What is the likely cause of a net::ERR_CONNECTION_ABORTED when uploading a file to Spring
  • Zend framework 2 : Add different authentication adapter for two different modules
  • Are there any libraries for Python to simulate keyboard action?
  • JavaScript IE rotation transform maths
  • C# - Most efficient way to iterate through multiple arrays/list
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Pass Dictionary to Javascript array
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • Read text file that is not in the main package in a runnable jar
  • Roxygen error “Skipping invalid path”
  • ImageMagick, replace semi-transparent white with opaque white
  • Cannot connect to cassandra from Spark
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Cross-Platform Protobuf Serialization
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • SetUp method failed while running tests from teamcity
  • Python: how to group similar lists together in a list of lists?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • Busy indicator not showing up in wpf window [duplicate]