【问题标题】:HTTP Status 404 - GrailsHTTP 状态 404 - Grails
【发布时间】:2015-10-02 05:32:48
【问题描述】:

我试图从 Grails 视图进入“http://localhost:8080/Twillio/smsService/index”。

我收到如下错误。

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

【问题讨论】:

  • 不是我测试过的,但可能是某种形式的冲突.. SmsServiceController Grails Controllers 文件必须以 Controller 结尾。 Grails Service 文件必须以 Service 结尾。如果它仍然不起作用,请尝试将其重命名为 SmsSerController 并查看是否有效

标签: grails twilio


【解决方案1】:

您必须在grails-app/views/smsService/index.gsp 处放置一个index.gsp

【讨论】:

  • grails-app/views/smsService 中没有 index.gsp,但仍然出现相同的错误。谢谢。我想我需要尝试不同的结构..
  • 如果我能发表评论,我会的 ;-)
猜你喜欢
  • 2018-03-05
  • 1970-01-01
  • 2015-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-09
相关资源
最近更新 更多