Home Ask Login Register

Developers Planet

Your answer is one click away!

creativeflow February 2016

Springboot not serving css content from html file

Good day, stack.

I've been stuck on this issue for a while, there are a lot of duplicates but mine differs slightly in that my code and hierarchy looks similar to others, but refuses to work. I'll jump right in and show my code.

The app

public class BookstoreApplication {

    public static void main(String[] args) {
        SpringApplication.run(BookstoreApplication.class, args);

The controller

public class HomeController {
    public ModelAndView showHome() {
        System.out.println("Showing home page");
        return new ModelAndView("test");

The config

public class WebConfig extends WebMvcConfigurerAdapter {
    public ViewResolver getViewResolver() {
        System.out.println("Settings up view resolver");
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        return resolver;

    public void configureDefaultServletHandling(
            DefaultServletHandlerConfigurer configurer) {
        System.out.println("Configuring servlet handling");

The html

<!doctype html>
<html lang="en" ng-app>
    <meta charset="utf-8">
    <title>Welcome to BooKart</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/app.css">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>

<div id="header-wrapper">
    <span class="logo pull-left">Book cart</span>
    <span class=        


creativeflow February 2016

The solution was to move the css folder under /WEB-INF/ to be /WEB-INF/css, for some reason having the files under static won't deploy. I'll leave it like this for now.

Post Status

Asked in February 2016
Viewed 2,901 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life