- Реализовал возможность загрузки файлов с клиента в директорию на сервере.

- Настроил доступ к статическим файлам, таким как картинки, стили, и т.д.

https://www.youtube.com/watch?v=bmMWrTMB5uo&list=PLU2ftbIeotGpAYRP9Iv2KLIwK36-o_qYk&index=10
This commit is contained in:
Leonid
2025-02-10 21:51:41 +03:00
parent 8d4c5e1b3a
commit 8580d4cfa6
9 changed files with 69 additions and 14 deletions

View File

@@ -5,3 +5,5 @@ spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.freemarker.expose-request-attributes=true
spring.freemarker.suffix=.ftl
upload.path=/home/kashey/soft/sweater/uploads

View File

@@ -0,0 +1,3 @@
body {
color: #191970;
}

View File

@@ -7,9 +7,10 @@
</div>
<div>
<form method="post">
<form method="post" enctype="multipart/form-data">
<input type="text" name="text" placeholder="Enter message" />
<input type="text" name="tag" placeholder="tag">
<input type="file" name="file">
<input type="hidden" name="_csrf" value="${_csrf.token}" />
<button type="submit">Add message</button>
</form>
@@ -30,6 +31,11 @@
<span>${message.text}</span>
<i>${message.tag}</i>
<strong>${message.authorName}</strong>
<div>
<#if message.filename??>
<img src="/img/${message.filename}">
</#if>
</div>
</div>
<#else>
No messages found

View File

@@ -4,6 +4,7 @@
<head>
<title>Sweater</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/static/style.css" rel="stylesheet" type="text/css" />
</head>
<body>