简体   繁体   English

我们可以使用@RequestParam(“ custCode”)获得id =“ CodeTxt”

[英]can we get id=“CodeTxt” using @RequestParam(“custCode”)

jsp: JSP:

<form:input mandatory="true" id="CodeTxt" path="custCode" cssClass="txtfield
 controlWidth" readonly="false"jsValidation="checkAlphaNumeric" />

Controller class: 控制器类:

public @ResponseBody JsonResult fetchCustomerList(@ModelAttribute("customer")Customer customer,@RequestParam("custCode") String customerCode

do we fetch our parameters with name or id if yes then how we are fetching the values from @RequestParam("custCode") .Are we mapping our parameter with path="custCode" ?? 是否使用name或id提取参数(如果是),那么我们如何从@RequestParam("custCode")提取值。是否将我们的参数映射为path="custCode" did JsonResult has done some thing behind the screen?? JsonResult在屏幕后面做了什么吗? this is a code snippet and running properly. 这是一个代码段,可以正常运行。

When you send a form request to a server, form data are available as key / value pairs, where the key is the name of the form field (HTML attribute name="custCode" is generated for you when you use: path="custCode" ). 当您向服务器发送表单请求时,表单数据可以作为键/值对使用,其中键是表单字段的name (使用时会为您生成HTML属性name="custCode"path="custCode" Id attribute is not relevant in this case and you cannot reference form field by its id instead of name attribute. 在这种情况下, Id属性不相关,因此无法通过其id而不是name属性来引用表单字段。

If you need to retrieve value of the id you can store it as an additional hidden field value for example: 如果您需要检索id值,则可以将其存储为其他隐藏字段值,例如:

<input type="hidden" name="custCodeFieldId" value="codeTxt"  /> 

and then retrieve the value of id using additional @RequestParam("custCodeFieldId") String custCodeFieldId 然后使用其他@RequestParam("custCodeFieldId") String custCodeFieldId检索id的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM