我知道有一些像我这样的问题,但我希望能够解释如何在Grails中做到这一点。
我想要做的是在按下提交按钮时将值从gsp datepicker和textfield传递给控制器。
我提前感谢
GSP:
<g:form action="generateReport">
<ol>
<li class="fieldcontain">
<div class="fieldcontain required">
<label for="date" style="padding-left: 210px;">
<g:message code="Data" default="Data"/>
<span class="required-indicator">*</span>
<g:datePicker id="data" name="datapicker" precision="day"></g:datePicker>
</label>
</div>
</li>
<li class="fieldcontain">
<div class="fieldcontain required">
<label for="date" style="padding-left: 195px;">
<g:message code="Time" default="Time"/>
<g:textField name="minutes"/>
</label>
</div>
</li>
</ol>
<div class="content scaffold-show" style="padding-left: 50px;">
<g:submitButton value="search" name="button"/>
</div>
</g:form>
控制器:
def generateReport(){
log.info("Button pressed")
redirect(action: "list")
}
答案 0 :(得分:1)
我刚刚找到答案:
观点:
<g:textField name="name" />
the controller:
控制器:
class SomeController {
def someAction() {
def name = params.name
// do something with name
}
}