├── HelloWorld ├── Student.java ├── StudentController.java ├── StudentRepository.java ├── application.properties ├── dependencies ├── javascript.html └── jss.js /HelloWorld: -------------------------------------------------------------------------------- 1 | package com.project.college.Controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloWorldController { 8 | 9 | @GetMapping("") 10 | public String helloWorld() { 11 | return "Hello World"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Student.java: -------------------------------------------------------------------------------- 1 | package com.project.college.entity; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.GeneratedValue; 5 | import jakarta.persistence.GenerationType; 6 | import jakarta.persistence.Id; 7 | 8 | @Entity 9 | public class Student { 10 | 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private Long id; 14 | private String name; 15 | private String email; 16 | private String phone; 17 | private String university; 18 | 19 | // Constructors, getters, and setters 20 | public Student() { 21 | } 22 | 23 | public Student(String name, String email, String phone, String university) { 24 | this.name = name; 25 | this.email = email; 26 | this.phone = phone; 27 | this.university = university; 28 | } 29 | 30 | public Long getId() { 31 | return id; 32 | } 33 | 34 | public void setId(Long id) { 35 | this.id = id; 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public void setName(String name) { 43 | this.name = name; 44 | } 45 | 46 | public String getEmail() { 47 | return email; 48 | } 49 | 50 | public void setEmail(String email) { 51 | this.email = email; 52 | } 53 | 54 | public String getPhone() { 55 | return phone; 56 | } 57 | 58 | public void setPhone(String phone) { 59 | this.phone = phone; 60 | } 61 | 62 | public String getUniversity() { 63 | return university; 64 | } 65 | 66 | public void setUniversity(String university) { 67 | this.university = university; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /StudentController.java: -------------------------------------------------------------------------------- 1 | package com.project.college.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.ModelAttribute; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | 12 | import com.project.college.entity.Student; 13 | import com.project.college.repository.StudentRepository; 14 | 15 | @Controller 16 | public class StudentController { 17 | 18 | @Autowired 19 | private StudentRepository repository; 20 | 21 | @GetMapping("/add-student") 22 | public String showAddStudentForm(Model model) { 23 | model.addAttribute("student", new Student()); 24 | return "create"; 25 | } 26 | 27 | @GetMapping("") 28 | public String showProfile(Model model) { 29 | List students = repository.findAll(); 30 | model.addAttribute("students", students); 31 | return "view"; 32 | } 33 | 34 | @PostMapping("/students") 35 | public String addStudent(Student student) { 36 | repository.save(student); 37 | return "redirect:/"; 38 | } 39 | 40 | @GetMapping("/update") 41 | public String updateStudentForm(Model model) { 42 | Student student = repository.findById(1L).orElse(null); 43 | model.addAttribute("student", student); 44 | return "update"; 45 | } 46 | 47 | @PostMapping("/update-student") 48 | public String updateStudent(@ModelAttribute("student") Student updatedStudent) { 49 | repository.save(updatedStudent); 50 | return "redirect:/"; 51 | } 52 | 53 | @PostMapping("/delete-student") 54 | public String deleteAllStudents() { 55 | repository.deleteAll(); 56 | return "redirect:/"; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /StudentRepository.java: -------------------------------------------------------------------------------- 1 | package com.project.college.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.project.college.entity.Student; 6 | 7 | public interface StudentRepository extends JpaRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/testdb 2 | spring.datasource.username=root 3 | spring.datasource.password=Root@1234 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect 6 | spring.jpa.hibernate.ddl-auto=create 7 | spring.thymeleaf.prefix=classpath:/templates/ 8 | spring.thymeleaf.suffix=.html 9 | spring.thymeleaf.cache=false 10 | spring.thymeleaf.mode=HTML -------------------------------------------------------------------------------- /dependencies: -------------------------------------------------------------------------------- 1 | Spring Web 2 | Spring Web Services 3 | Spring BootDevTools 4 | Spring Data JPA 5 | MySQL Driver 6 | -------------------------------------------------------------------------------- /javascript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 |

ToDo List

11 |
12 |
13 | 14 | 15 | 16 |
17 | 18 |
19 |
20 |

Task 1

21 | 22 |
23 |
24 |
25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /jss.js: -------------------------------------------------------------------------------- 1 | //document.write("welcome to java script") 2 | function AddTask() 3 | { 4 | var input=document.getElementById('input1').value 5 | var element = document.getElementById('task-container') 6 | console.log(element) 7 | var newElement= document.createElement('div') 8 | newElement.setAttribute('id', 'individual-container') 9 | newElement.innerHTML=`

${input}

` 10 | element.append(newElement) 11 | } 12 | function DeleteTask(event) 13 | { 14 | event.target.parentElement.remove() 15 | 16 | } 17 | 18 | 19 | --------------------------------------------------------------------------------