2014-10-22 1 views
0

컨트롤러가 2 개 있습니다. PollController 및 api.PollApiController.Grails URL Api 매핑이 잘못된 컨트롤러를 호출합니다.

My PollController는 일반적인 컨트롤러입니다.

class PollApiController extends RestfulController { 

    static responseFormats = ['json', 'xml'] 

    PollApiController() { 
     super(Poll) 
    } 
} 

이 내 URL-매핑은 다음과 같습니다 :

class UrlMappings { 

    static mappings = { 
     "/$controller/$action?/$id?(.$format)?"{ 
      constraints { 
       // apply constraints here 
      } 
     } 

     "/api/poll"(resources:'poll', controller:'pollApiController') 
    } 
} 

내 문제는 내가/API-전화 Grails를 할 때마다이 PollController 대신 PollApiController 실행되는 이 API-컨트롤러는 RestfulController을 상속 . PollController를 변경하면 확인할 수 있습니다. RestfulController에서 처음으로 작업 할 때 무엇이 ​​잘못 되었습니까?

답변

1

RestfulController에 매핑하면 controller 매개 변수가 필요하지 않습니다. 대신 resources은 (안정) 컨트롤러의 기본 이름으로 설정해야합니다.

"/api/poll"(resources: 'pollApi') 

자세한 내용은 다음을 참조하십시오 http://grails.org/doc/latest/guide/single.html#restfulMappings

관련 문제