Missing URI template variable 'employeeNumber' for method parameter of type String
来源:互联网 发布:哈工大机械考研知乎 编辑:程序博客网 时间:2024/05/21 19:31
使用SpringMVC参数注解@PathVariable时出错提示:
Missing URI template variable 'employeeNumber' for method parameter of type String
@RequestMapping(value = "/findUserByEmployeeNumber/{EmployeeNumber}",method = RequestMethod.GET) public ResponseEntity<TodoUser> findByNumber(@PathVariable @Valid String employeeNumber){ ... }
如果@RequestMapping中表示为”item/{id}”,id和形参名称一致,@PathVariable不用指定名称。如果不一致,例如”item/{ItemId}”则需要指定名称@PathVariable(“itemId”)。
因此原代码中的参数
@RequestMapping(value = "/findUserByEmployeeNumber/{EmployeeNumber}
中{EmployeeNumber}变量名需要和@PathVariable @Valid String employeeNumber
中一样
修改后:
- 方法一:参数名一致
@RequestMapping(value = "/findUserByEmployeeNumber/{employeeNumber}",method = RequestMethod.GET) public ResponseEntity<TodoUser> findByNumber(@PathVariable @Valid String employeeNumber){ ... }
- 方法二:添加别名
@RequestMapping(value = "/findUserByEmployeeNumber/{employeeNumber}",method = RequestMethod.GET) public ResponseEntity<TodoUser> findByNumber(@PathVariable("employeeNumber") @Valid String Number){ ... }
注意两个区别
- @PathVariable是获取url上数据的。
- @RequestParam获取请求参数的(包括post表单提交)
更多SpringMVC用法详见本人博客SpringMVC02教程
- Github项目使用SpringMVC总结
阅读全文
0 0
- Missing URI template variable 'employeeNumber' for method parameter of type String
- Parameter \' \': No size set for variable length data type: String
- Parameter 'p_REMARK': No size set for variable length data type: String.
- dwr报警Missing type info for method(0). Assuming this is a map with String keys
- missing method or missing parameter
- proguard Missing type parameter
- proguard Missing type parameter
- No parameter name specified for argument of type [java.lang.String]
- No parameter name specified for argument of type [java.lang.String],
- 错误: default argument missing for parameter 2 of
- No parameter name specified for argument of type
- he method isEmpty() is undefined for the type String/String
- The method isEmpty() is undefined for the type String/String
- variable type of buffer_handle_t
- The method contains(CharSequence) from the type String refers to the missing type CharSequence错误解决方法
- The method contains(CharSequence) from the type String refers to the missing type CharSequence错误解决方法
- The method update(String, Object...) from the type JdbcTemplate refers to the missing type DataAcces
- the method getcontextpath() from the type httpservletrequest refers to the missing type string
- dojox/layout/FloatingPane浮动面板小部件
- Linux学习总结(38)——Linux超实用的30个命令
- Coursera算法课程中如何在eclipse中调用外部库stdlib.jar
- 基于Aspectj的注解操作
- 【代码笔记】iOS-自定义switch
- Missing URI template variable 'employeeNumber' for method parameter of type String
- 基本数据类型知识点整理
- 2017 Multi-University Training Contest
- 自定义Dialog弹框和其背景阴影显示
- 如何在Linux终端里用Shell和C输出带颜色的文字
- Python day04 商户、购物双平台创建 import用法实例
- 名字空间
- 调用手机陀螺仪
- 使用XmlDocument创建XML文档及增加删除更新节点