我试图进入" http://localhost:8080/Twillio/smsService/index"来自Grails的观点。
我得到如下错误。
HTTP状态404 - " /WEB-INF/grails-app/views/smsService/index.gsp"没找到。
我用于SmsServiceController.groovy的代码如下。
package twillio
class SmsServiceController {
def index () {}
def smsService
def twilioHttpEndpointBean
def read = { withFormat { html {} } }
def create = { SendSmsCommand cmd ->
def validMessage = cmd.validate();
log.debug "Incoming message is ${validMessage ? 'valid' : 'invalid'}"
log.debug "Format is ${request.format}"
withFormat {
json {
if (validMessage) {
def smsResponse
try {
smsResponse = smsService.send(cmd.destination, cmd.message)
render(contentType: "application/json") {
result(success: true)
}
} catch (Exception e) {
render(contentType: "application/json", status: 500) {
result(success: false, message: e.message)
}
}
} else {
render(contentType: "application/json", status: 500) { result(success: false) }
}
}
}
}
}
class SendSmsCommand {
String destination
String message
static constraints = {
message(size: 1..140)
}
}
答案 0 :(得分:1)
您必须在index.gsp
grails-app/views/smsService/index.gsp