request.withFormat { form { redirect humanInstance //Explain : old grails redirect like redirect(action: "show", id: humanInstance.id) //but in 2.3.0 by redirect humanInstance this statement i saw it goes to def show(Human humanInstance) action //Q1: how it understand that it has to redirect def show(Human humanInstance) action ? //cause here so many methods which receives humanInstance //Q2: And where it get processed ? } '*' { respond humanInstance, [status: CREATED] } //Explain : I tested it that in the above {works for normalCall}'*'{works for restCall} //Q3: What is '*' operator do here what it's name? }
답변
'*'는 다른 블록이 해당 블록과 일치하지 않을 때 실행해야하는 코드 블록과 관련된 종류의 catch-all입니다. 수락 헤더. 다음을 참조하십시오 ...
request.withFormat {
xml {
// execute this if the request content type is xml
}
json {
// execute this if the request content type is json
}
'*' {
// execute this if neither of the other 2 matched the request's content type
}
}
구성한 MIME 유형을 포함하여이 문제를 이해하고 싶을 것입니다. 공식 사용자 가이드의 Content Negotiation 섹션을 http://grails.org/doc/2.3.x/guide/theWebLayer.html#contentNegotiation으로보아야합니다.
도움이되기를 바랍니다.
UPDATE :
당신이 (someDomainClassInstance)를 재 호출하면 https://github.com/grails/grails-core/blob/v2.3.8/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultLinkGenerator.groovy#L175를 호출 https://github.com/grails/grails-core/blob/v2.3.8/grails-plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/web/metaclass/RedirectDynamicMethod.java#L160
에서 끝낸다.
이 시점에서 "method"의 값은 "GET_ID"입니다. GET_ID와 연결된 https://github.com/grails/grails-core/blob/v2.3.8/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultLinkGenerator.groovy#L56의 값은 "show"이며 이는 show 메소드로 리디렉션 할 것을 지시합니다.
- 1. Grails 2.3.0 뷰 렌더링 문제
- 2. 컨트롤러에서 j_spring_security_logout으로 리다이렉트
- 3. Grails : 컨트롤러에없는 index.gsp로 리다이렉트
- 4. NGINX - 리다이렉트 된 응답
- 5. 스프링 컨트롤러에서 리다이렉트 플로우를 처리하는 방법
- 6. grails 2.3.0 용 mongodb gorm 플러그인 버전?
- 7. Grails : 통합 테스트로 리다이렉트 테스트하기
- 8. grails 컨트롤러에서 쿼리를 작성하는 방법
- 9. 컨트롤러에서 save(), Grails
- 10. grails 컨트롤러에서 JSON을 구문 분석하는 방법
- 11. 통합 테스트에서 Grails 응답 맵
- 12. 컨트롤러에서 Grails 로깅
- 13. Grails 컨트롤러에서 전역 변수 설정 및 액세스하기
- 14. HTTPS 프로토콜을 사용하여 리다이렉트 전용 Grails/Weblogic
- 15. 컨트롤러에서 다른 컨트롤러로 Cakephp 내부 리다이렉트
- 16. Grails, SpringSecurity - 로깅되지 않은 경우 리다이렉트 해제하기
- 17. Grails 컨트롤러에서 JSON으로 선택 상자를 채우는 방법
- 18. grails 컨트롤러에서 드라이버 연결을 알 수있는 방법
- 19. Grails : jScience 금액 저장 방법
- 20. Grails JSON 요청 및 응답 처리하기
- 21. Grails 파일 업로드 json 응답
- 22. grails : 컨트롤러에서 데이터베이스에 엔트리 생성
- 23. Grails 컨트롤러에서 비디오 콘텐츠 렌더링
- 24. Node.js 및 응답 작동 방식 이해
- 25. 컨트롤러에서 json 응답 받기
- 26. 응답 및 리다이렉트 중 하나에 대한 답장 laravel 4
- 27. Grails g : remoteLink 응답
- 28. Android : 이상한 응답, PHP 로그인으로부터의 가능한 리다이렉트
- 29. grails 내의 컨트롤러에서 복합 Json 객체 응답을 테스트하는 방법 2.4.3
- 30. 모델 레코드로드, 편집 및 컨트롤러에서 저장
감사합니다. 제프, 제 3의 좋은 대답은 대답 할 수 있었습니까? 대답 –
답변이 너무 길어서이 답변에 답을 추가했습니다. 나는 몇 가지 질문을 보았고 몇 가지 질문을 하나의 게시물에 쌓기 때문에 대부분 답답하고 일관성이없는 부분은 비 일관적인 부분에 의해 불필요하게 복잡해 지므로 실제로해야하는 것보다 더 많은 노력이 필요합니다 도움이되는 정보를 제공합니다. 서로 조화를 이루지 않고 더 단순하게 지키면 질문에 답하기가 더 쉬울 것입니다. –
두 번째 답변을 삭제하고 그 내용을 이미 수락 된 첫 번째 답변에 붙여 넣었습니다. 나는이 문제를보다 쉽게 보게 될 것이라고 생각합니다. –