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

@SpringBootApplication
public class BookstoreApplication {

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

The controller

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

The config

@Configuration
@EnableWebMvc
@ComponentScan("com.sean.books")
public class WebConfig extends WebMvcConfigurerAdapter {
    @Bean
    public ViewResolver getViewResolver() {
        System.out.println("Settings up view resolver");
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/html/");
        resolver.setSuffix(".html");
        return resolver;
    }

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

The html

<!doctype html>
<html lang="en" ng-app>
<head>
    <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>
</head>
<body>

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

Answers


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

Search




Leave an answer