I am using thymeleaf along with springboot
I am not able to view any images in my HTML file. I have tried all different ways of doing the same in thymeleaf but no luck.
Here is my project folder structure
🗁 src
└─── 🗁 main
└─── 🗁 resources
├─── 🗁 templates
├─── 🗁 css
└─── 🗁 images
HTML File
<head>
<title>Community Bike Share Web Application</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<link rel="stylesheet" th:href="@{/webjars/bootstrap/3.1.1/css/bootstrap.min.css}" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
</head>
<div>
<img th:src="@{/images/taiwan_Bicycle_Ride_hd_wallpaper_8.jpg}"
src="../images/taiwan_Bicycle_Ride_hd_wallpaper_8.jpg" class="img-responsive" alt="Responsive image"/>
</div>
Thymeleaf Templatehtml in the path src/main/resources/templates. This template displays an HTML form to allow the user to select and upload an image. Furthermore, we use the accept=”image/*” attribute to allow users to import images only instead of importing any kind of files.
1.1. Spring Boot will provide auto-configuration for Thymeleaf. Add spring-boot-starter-thymeleaf dependency in pom. xml to enable this auto-configuration. No other configurations required, Spring Boot will inject all required configuration to work with Thymeleaf.
It provides full integration with Spring Framework. It applies a set of transformations to template files in order to display data or text produced by the application. It is appropriate for serving XHTML/HTML5 in web applications. The goal of Thymeleaf is to provide a stylish and well-formed way of creating templates.
With Boot's default configuration, your images (and other static content), need to be beneath src/main/resources/static
. For example, to serve content from /images
put the files in src/main/resources/static/images
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With