2011-03-03 4 views
4

안녕하세요, grails에서 urlmapping에 대한 질문이 있습니다. 나는 seo friendly URL을 페이지 이름과 ID를 사용하여 만들려고 노력하고 있습니다. http://localhost:8080/SuurdGasControl/2/GasmetingenID와 이름을 사용하는 Grails urlmapping

: 아이디는 urlbar에서 명확하지 나는 모든 것이 잘가는 링크를 클릭합니다 처음 있도록 ....

class UrlMappings { 

static mappings = { 
    "/$id/$name"{ 
     controller = "page" 
     action = "view" 
    } 
    "500"(view:'/error') 
    "/"(controller:"index") 
    } 
} 

마녀가 작동하지만 : 나는 내 URLMapping에서 follwing을 얻었다

그러나 다음 페이지가 표시됩니다 : 아이디 "2"제거되지 않았 음을 http://localhost:8080/SuurdGasControl/2/6/Ontgassen

메모를 ...

어떤 도움이나 생각?

UPDATE

URLMapping 이제 다음과 같습니다 http://docs.grails.org/latest/guide/theWebLayer.html#namedMappings에 설명 된대로 명명 된 URL 매핑을 사용하는

<g:link mapping="stfu" params="[id: pageId, name: pageName]">${oNavigationInstance.toString()}</g:link> 

답변

3

시도 : 링크를 생성

class UrlMappings { 

    static mappings = { 
    "/$controller/$action?/$id?"{ 
     constraints { 
       // apply constraints here 
     } 
    } 

    name stfu: "/id/$id/$name" { 
     controller = 'page' 
     action = 'view' 
    } 

    "500"(view:'/error') 
    "/"(controller:"index") 

    } 
} 

는 것만 큼 간단합니다

+0

도움을 주신 Thnx! – BadSkillz

관련 문제