Create controller for handling crud request
This commit is contained in:
parent
786dfb637b
commit
e24e471563
|
@ -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"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue