If in a domain class try:
def matches = Book.findAllByTitleLike("wonderful")
/ :
def matches = Book.findAllByTitleILike("wonderful")
:
def books = ['Wonderful Tonight', 'Atlas Shrugged', 'A Tale of Two Cities']
def matches = books.findAll{it.indexOf("wonderful") > -1}
matches = books.findAll{it.indexOf("Wonderful") > -1}
matches = books.findAll{it.toLowerCase().indexOf("wonderful") > -1}
Update:
, , , .
, , , .
:
grails-app/views/entry/ search.gsp :
<g:form controller='entry' action='searchResults'>
Entry Title: <g:textField name="title" value="${title}" />
Entry Date: <g:datePicker name="day" value="${day}" precision="day" />
<g:submitButton name="submit" value="Search" />
</g:form>
. grails-app/controller/ EntryController.groovy. , "grails create-Control Entry", EntryController.
:
def search = {
render(view:'search')
}
def searchResults = {
def entryCriteria = Entry.createCriteria()
def results = entryCriteria.list {
if(params?.title) {
ilike{"title","%${params.title}%"
}
if(params?.day) {
eq("eventDate", params.day)
}
}
render(view:'searchResults', model:['results':results])
}
, searchResults.gsp grails-app/views/entry
<h1>Results</h1>
<g:each in=${results}>
${it}
</g:each>
, :
- localhost: 8080/${appName}/entry/search, .
- / , .
- ,
- , gsp .
, " " , , , . , , . .
, :
- , , , .
- ; , .
- , searchResults, Grails, , . , - .
- ; Entry , .
, . . searchResults :
def results = Entry.findByTitleILike(params?.title)
, .
!