Skip to content
Snippets Groups Projects
Commit 9f3c1b62 authored by Syed Hyder's avatar Syed Hyder
Browse files

imports fixed

parent 5d392b22
Branches
No related tags found
No related merge requests found
......@@ -26,6 +26,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
......
package com.project.cms;public class person {
package com.project.cms;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
private class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String email;
private String complaint;
// getters and setters
}
package com.project.cms;public class personcontroller {
package com.project.cms;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@Controller
public class personcontroller {
@Autowired
private PersonRepository personRepository;
@GetMapping("/complaints")
public String viewAllComplaints(Model model) {
List<Person> allComplaints = personRepository.findAll();
model.addAttribute("complaints", allComplaints);
return "complaints";
}
}
package com.project.cms;public class repository {
package com.project.cms;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PersonRepository extends JpaRepository<Person, Long> {
}
//needs to be fixed when
// is sorted
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>$Title$</title>
<meta charset="UTF-8">
<title>Complaints</title>
</head>
<body>
$END$
<h2>Complaints</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Complaint</th>
</tr>
</thead>
<tbody>
<tr th:each="complaint : ${complaints}">
<td th:text="${complaint.id}"></td>
<td th:text="${complaint.name}"></td>
<td th:text="${complaint.email}"></td>
<td th:text="${complaint.complaint}"></td>
</tr>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment