2015-10-02 218 views
0

我试图从Grails视图进入“http://localhost:8080/Twillio/smsService/index”。HTTP状态404 - Grails

和我得到如下错误。

HTTP Status 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

不,我测试,但可能是某种形式的冲突.. SmsServiceController的Grails控制器文件必须与控制器结束的。 Grails服务文件必须以Service结尾。如果它仍然无法正常工作,请尝试将其重命名为SmsSerController并查看是否有效 – Vahid

回答

1

你必须放置在index.gspgrails-app/views/smsService/index.gsp

+0

grails-app/views/smsService中没有index.gsp,但仍然出现相同的错误。谢谢。我想我需要尝试不同的结构.. –

+0

我会,如果我能够留下评论;-) – aveltens