Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Spring Basics Creating Controllers and Views Adding Static Assets

Arn贸r Kristmundsson
Arn贸r Kristmundsson
2,013 Points

I can't link the HTML-page the CSS file following Chris' steps

Following Chris' steps, the HTML-page won't link to the CSS. Many on Stackoverflow seem to have similar problem. But I haven't found any better solution than to put the CSS into a style element. Could it be that we have to configure the resource location in the configuration file?

my current solution is

<!--link rel="stylesheets" type="text/css" href="../static/css/app.css" th:href="@{/css/app.css}"/-->
<style>
@import url(https://fonts.googleapis.com/css?family=Varela+Round);
body {
    font-family: 'varela round', sans-serif;
}
h1 {
    padding: 10px;
    background-color: #896bb3;
    color: #ffffff;
}
</style>

(I moved the CSS file into a subdirectory of its own, like we did with the gif)

Arn贸r Kristmundsson
Arn贸r Kristmundsson
2,013 Points

Haha of course, I should have tried to open the home page in a browser and then I would have seen that the problem had nothing to do with spring. Many thanks!

1 Answer

Matthew Jeng
Matthew Jeng
9,242 Points

I can't say for sure, but it's possible it's because you have rel="stylesheets" when I believe it should be rel="stylesheet" (singular).