문제

I have inputtext filed in my gsp llike this :

<tr class="context">
    <td width="5%" ><a class="addButton" href="#" style="display:none;"  >+</a></td>
    <td width="60%"><input type="text" name="iwd0_description" value="" id="iwd0_description" /></td>                   
    <td width="10%"><input type="text" name="iwd0_tax" value="" id="iwd0_tax" /></td>
    <td width="10%"><input type="text" name="iwd0_discount" value="" id="iwd0_discount" /></td>
    <td width="10%"><input type="null" name="iwd0_total" value="0" required="" id="iwd0_total" /></td>
    <td width="5%" ><a class="deleteButton" href="#"  style="display:none;" >-</a></td>
</tr>

<tr class="context">
    <td width="5%" ><a class="addButton" href="#"     style="display:none;"  >+</a></td>
    <td width="60%"><input type="text" name="iwd1_description" value="" id="iwd1_description" /></td>                   
    <td width="10%"><input type="text" name="iwd1_tax" value="" id="iwd1_tax" /></td>
    <td width="10%"><input type="text" name="iwd1_discount" value="" id="iwd1_discount" /></td>
    <td width="10%"><input type="null" name="iwd1_total" value="0" required="" id="iwd1_total" /></td>
    <td width="5%" ><a class="deleteButton" href="#"  style="display:none;" >-</a></td> 
</tr>

How can I access to input value in my controller?

올바른 솔루션이 없습니다

다른 팁

Form values are sent over HTTP using request parameters (for GET requests), with the input name attribute used to set the parameter "key". So your HTTP request will have the following params: ?iwd0_tax=userInput1&iwd0_discount=userInput2 etc.

Grails makes request parameters available by the params var in controllers:

def iwd0_tax = params.iwd0_tax

Grails can also populate a bean/class from the request params automatically. The bean is called a command object. See details in the Grails docs.

def i = 0
while (params."iwd${i}_tax") {          
    println 'tax'+"${i}" + params."iwd${i}_tax"                     
    i++
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top