... ...
<g:textField name="firstName" value="${parsing.retrieveContentsOfTag(stringToParse: firstName)}"/>
<g:textField name="lastName" value="${parsing.retrieveContentsOfTag(stringToParse: lastName)}"/>
이이 같은 컨트롤러에서 렌더링한다면 ... 생처럼 보이는 HTML 초래
// grails-app/controllers/com/demo/DemoController.groovy
package com.demo
class DemoController {
def index() {
// these values wouldn't have to be hardcoded here of course...
[firstName: '<Jeff>', lastName: '<Brown>']
}
}
s ...
<input type="text" name="firstName" value="Jeff" id="firstName" />
<input type="text" name="lastName" value="Brown" id="lastName" />
나는 희망한다.
UPDATE :
당신이 정말로 무엇을하려고에 따라, 당신은 또한이 같은 것을 사용하여 태그 내에 전체 텍스트 필드 생성 일을 마무리에서 같을 수 있습니다 ...
// grails-app/taglib/com/demo/ParsingTagLib.groovy
package com.demo
class ParsingTagLib {
static namespace = 'parsing'
def mySpecialTextField = { attrs ->
// The regex handling here is very
// crude and intentionally simplified.
// The question isn't about regex so
// this isn't the interesting part.
def matcher = attrs.stringToParse =~ /<(\w*)>/
def value = matcher[0][1]
out << g.textField(name: attrs.name, value: value)
}
}
그런 다음 GSP 코드는
<parsing:mySpecialTextField name="firstName" stringToParse="${firstName}"/>
<parsing:mySpecialTextField name="lastName" stringToParse="${lastName}"/>
무엇 반환 할 필요합니까 ... 같이 수 있을까? 'Matches '를 수집하는 이유는'Matches '가 필요하지 않지만'String' 만 믿으시겠습니까? 어쨌든 도메인 클래스의 인스턴스를 Model 파트로 전달하고 GSP에서 호출하십시오. 정확히 어떻게 - 텍스트 필드에서 무엇을해야하는지에 따라 GSP 코드 샘플이 도움이 될 것입니다. –