Create controller for handling crud request

This commit is contained in:
Mariusz Kuligowski 2018-03-15 23:56:12 +01:00
parent 786dfb637b
commit e24e471563
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package com.baeldung.grails
class StudentController {
StudentService studentService
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
def index() {
respond studentService.list()
}
def show(Long id) {
respond studentService.get(id)
}
def create() {
respond new Student(params)
}
def save(Student student) {
studentService.save(student)
redirect action:"index", method:"GET"
}
def delete(Long id) {
studentService.delete(id)
redirect action:"index", method:"GET"
}
}