Static Content with MVC

11 views
Skip to first unread message

Victor Osório

unread,
Jul 2, 2020, 9:49:55 PM7/2/20
to MVC 1.0 Users Mailing List

I'm trying to create an example using MVC 1.0.


It is working for all views, but not for static content. I have a simple Hello World here https://github.com/vepo/java-mvc-hello-world


If I execute it, I get 404 on /assets/css/main.css


Is something missing?


Thanks,

Victor Osório

Tobias Erdle

unread,
Jul 3, 2020, 3:56:13 AM7/3/20
to MVC 1.0 Users Mailing List
Hi Victor,

I had a look into your code and recognized that the context path for the asset is missing. Also, it's not recommended by the spec to map the application path to "/", as this may lead to unexpected behavior when forwards are handled by the server.
So to load the assets, please try to change your @ApplicationPath to something else than "/" and prefix the asset path with  #{request.contextPath} and your asset should be resolved.

Best regards,

Tobias
Reply all
Reply to author
Forward
0 new messages