Line1:
public ModelAndView viewCustomerDetails(@RequestParam("custId") Integer customerId, @RequestParam("categoryName") String categoryName, HttpServletRequest request) throws BusinessException{
Line2:
public ModelAndView viewCustomerDetails(@RequestMapping("custId") Integer customerId, @RequestMapping("categoryName") String categoryName, HttpServletRequest request) throws BusinessException{
我正在查看我的项目代码,但有些困惑@RequestParam
and @RequestMapping
有时我发现@RequestParam
有时@RequestMapping
。据我了解,两者都会分配以下值custId
to customerId
数据成员。
我的 jsp 文件的某些部分:
<form:input mandatory="true" id="CustNameTxt" path="custName" cssClass="txtfield controlWidth" readonly="false" />
为了更好地理解我的问题,我在 Line2 中进行了编辑
您将苹果与梨进行比较。这两个注释没有任何共同点,除了这是 Spring MVC 注释,以及您对@RequestMapping("categoryName")
is wrong!
-
@RequestMapping
是一个类或方法注释,用于将请求 url 映射到 java 方法。
-
@RequestParam
是一个(方法)字段注释,用于将请求参数绑定到方法参数
也许你捣碎了@RequestMapping
with @PathVariable
,你的问题是关于@RequestParam
and @PathVariable
-然后看看这个answer https://stackoverflow.com/a/13718502/280244.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)