Починил проект, начал делать страницы, но они не отображаются
This commit is contained in:
parent
464b611b41
commit
ab60694642
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.springframework.boot' version '3.2.5'
|
id 'org.springframework.boot' version '3.2.3'
|
||||||
id 'io.spring.dependency-management' version '1.1.4'
|
id 'io.spring.dependency-management' version '1.1.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,10 +28,11 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter:2.4.5'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
|
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
|
||||||
implementation 'org.modelmapper:modelmapper:3.2.0'
|
implementation 'org.modelmapper:modelmapper:3.2.0'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-devtools'
|
||||||
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||||
implementation 'org.postgresql:postgresql'
|
implementation 'org.postgresql:postgresql'
|
||||||
|
@ -1,29 +1,11 @@
|
|||||||
package com.example.autoservice;
|
package com.example.autoservice;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
import com.example.autoservice.clients.service.ClientsService;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class AutoserviceApplication implements CommandLineRunner {
|
public class AutoserviceApplication {
|
||||||
|
|
||||||
private final ClientsService clientsService;
|
|
||||||
public AutoserviceApplication(ClientsService clientsService) {
|
|
||||||
this.clientsService = clientsService;
|
|
||||||
}
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(AutoserviceApplication.class, args);
|
SpringApplication.run(AutoserviceApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String... args) throws Exception {
|
|
||||||
if (args.length > 0 && Objects.equals("--populate", args[0])) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.example.autoservice.clients.api;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.example.autoservice.core.configuration.Constants;
|
import com.example.autoservice.core.configuration.Constants;
|
||||||
|
|
||||||
import com.example.autoservice.clients.service.ClientsService;
|
import com.example.autoservice.clients.service.ClientsService;
|
||||||
import com.example.autoservice.clients.model.ClientsEntity;
|
import com.example.autoservice.clients.model.ClientsEntity;
|
||||||
|
|
||||||
@ -29,10 +31,6 @@ public class ClientsController {
|
|||||||
this.modelMapper = modelMapper;
|
this.modelMapper = modelMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String showClientsPage(){
|
|
||||||
return "clients";
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClientsDto toDto(ClientsEntity entity) {
|
private ClientsDto toDto(ClientsEntity entity) {
|
||||||
return modelMapper.map(entity, ClientsDto.class);
|
return modelMapper.map(entity, ClientsDto.class);
|
||||||
}
|
}
|
||||||
@ -40,6 +38,15 @@ public class ClientsController {
|
|||||||
private ClientsEntity toEntity(ClientsDto dto) {
|
private ClientsEntity toEntity(ClientsDto dto) {
|
||||||
return modelMapper.map(dto, ClientsEntity.class);
|
return modelMapper.map(dto, ClientsEntity.class);
|
||||||
}
|
}
|
||||||
|
@GetMapping("/page1")
|
||||||
|
public String handlePage1(){
|
||||||
|
return "page1";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/error")
|
||||||
|
public String handleError() {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public List<ClientsDto> getAll() {
|
public List<ClientsDto> getAll() {
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>Clients</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>CLIENTS</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
11
src/main/resources/templates/error.html
Normal file
11
src/main/resources/templates/error.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<title>Error</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Error</h1>
|
||||||
|
<p>An unexpected error occurred. Please try again later.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
src/main/resources/templates/index.html
Normal file
10
src/main/resources/templates/index.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Getting Started: Serving Web Content</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>Get your clients <a href="/page1">here</a></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
31
src/main/resources/templates/page1.html
Normal file
31
src/main/resources/templates/page1.html
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<title>Getting Started: Serving Web Content</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>First Name</th>
|
||||||
|
<th>Last Name</th>
|
||||||
|
<th>Middle Name</th>
|
||||||
|
<th>Date of Birth</th>
|
||||||
|
<th>Phone Number</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="client : ${clients}">
|
||||||
|
<td th:text="${client.id}"></td>
|
||||||
|
<td th:text="${client.firstName}"></td>
|
||||||
|
<td th:text="${client.lastName}"></td>
|
||||||
|
<td th:text="${client.middleName}"></td>
|
||||||
|
<td th:text="${client.dateOfBirth}"></td>
|
||||||
|
<td th:text="${client.phoneNumber}"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user