HTML 선택으로 생성 할 수 있도록 옵션을 쓰려면 어떻게해야합니까? 이 문제는 "옵션"이 배열이 아니라 집합이 필요하다는 것입니다.g : select 태그에 대한 세트를 작성하는 방법
여기에 제가 가진 모든 것이 있습니다. 나는 명명 규칙이 나쁘다는 것을 안다. 나는 그것을 고칠 것이다. 그러나 지금 당장은이 문제에 대해 며칠 동안 지켜보고있다.
컨트롤러 클래스
import org.springframework.dao.DataIntegrityViolationException
import grails.plugin.mail.*
class EmailServiceController {
static defaultAction = "contactService"
def contactService() {
def options = new ArrayList()
options.push("Qestions about service")
options.push("Feedback on performed service")
options.push("Other")
options.push("Why am I doing this")
options
}
def send() {
sendMail(){
to "[email protected]"
from params.email
subject params.subject
body params.information
}
}
}
도메인 클래스
class EmailService {
static constraints = {
}
}
g :
<g:select name = "subject" from = "${options}" noSelection="Topic"/>
는 또한 ""$ {selectOptions} "을 다음과 대신을 시도 GSP에서 선택 호출 $ {options} "행운 없음
def selectOptions() {
def options = new ArrayList()
options.push("Qestions about service": "QAS")
options.push("Feedback on performed service":"FoPS")
options.push("Other":"Other")
options.push("Why am I doing this":"WHY")
return options
}
왜 당신이이'대신'List'의 Set' 필요가 있다고 생각합니까 여기에 적절한 방법인가? – doelleri
@doelleri 스택 추적 : 메소드의 서명이 없습니다. java.lang.String.entrySet()은 인수 유형에 적용 가능합니다.() 값 : [] 가능한 해결책 : toSet(), toSet(), getBytes(), every() –