java-tutorials/grails/grails-app/controllers/com/baeldung/grails/StudentController.groovy

31 lines
599 B
Groovy

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"
}
}