Java 我们能得到id=”吗;CodeTxt";使用@RequestParam(“custCode”)

Java 我们能得到id=”吗;CodeTxt";使用@RequestParam(“custCode”),java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,jsp: 控制器类: public@ResponseBody JsonResult fetchCustomerList(@modeldattribute(“customer”)customer,@RequestParam(“custCode”)字符串customerCode 我们是否使用名称或id获取参数?如果是,那么我们如何从@RequestParam(“custCode”)获取值。我们是否使用path=“custCode”映射参数?? JsonResult在屏幕后面做了什么吗?? 这是一

jsp:


控制器类:

public@ResponseBody JsonResult fetchCustomerList(@modeldattribute(“customer”)customer,@RequestParam(“custCode”)字符串customerCode

我们是否使用名称或id获取参数?如果是,那么我们如何从
@RequestParam(“custCode”)
获取值。我们是否使用
path=“custCode”
映射参数?? JsonResult在屏幕后面做了什么吗??
这是一个代码片段,运行正常。

当您向服务器发送表单请求时,表单数据可以作为键/值对使用,其中键是表单字段的
名称
(使用时会为您生成HTML属性
name=“custCode”
).
Id
属性在这种情况下不相关,您不能通过表单字段的
Id
而不是
name
属性来引用表单字段

如果需要检索
id
的值,可以将其存储为附加的隐藏字段值,例如:

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

然后使用附加的
@RequestParam(“custCodeFieldId”)字符串custCodeFieldId

因此在屏幕后面添加name=“custCode”等name属性,以便我们可以作为@RequestParam(“custCode”)访问它是的,您现在理解正确了-顺便说一句,查看生成内容的最佳方法是使用一些页面源代码视图查看最终的HTML代码,或者使用Firebug(Firefox插件)检查生成的HTML元素。
<input type="hidden" name="custCodeFieldId" value="codeTxt"  />