jsp:
<form:input mandatory="true" id="CodeTxt" path="custCode" cssClass="txtfield
controlWidth" readonly="false"jsValidation="checkAlphaNumeric" />
Controller 类:
public @ResponseBody JsonResult fetchCustomerList(@ModelAttribute("customer")Customer customer,@RequestParam("custCode") String customerCode
我们是否使用名称或 ID 获取参数(如果是),那么我们如何从 @RequestParam("custCode")
获取值。我们是否使用 path="custCode 映射我们的参数“
?
JsonResult 是否在屏幕后面做了一些事情?
这是一个代码片段并且运行正常。
最佳答案
当您向服务器发送表单请求时,表单数据以键/值对的形式提供,其中键是表单字段的 name
(HTML 属性 name="custCode当您使用:
)。 path="custCode"
时,会为您生成“Id
属性在这种情况下不相关,您不能通过其 id
而不是 name
属性来引用表单字段。
如果您需要检索 id
的值,您可以将其存储为附加隐藏字段值,例如:
<input type="hidden" name="custCodeFieldId" value="codeTxt" />
然后使用附加方法检索 id 的值
@RequestParam("custCodeFieldId") 字符串 custCodeFieldId
关于java - 我们可以使用 @RequestParam ="CodeTxt"获取 id ("custCode"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31400732/