当前位置:网站首页>Missing URI template variable ‘employeeNumber‘ for method parameter of type String
Missing URI template variable ‘employeeNumber‘ for method parameter of type String
2022-08-09 10:50:00 【天T.】
使用SpringMVC参数注解@PathVariable时出错提示:
Missing URI template variable ‘employeeNumber’ for method parameter of type String
/** * 通用上传请求 */
@PostMapping("/common/upload1")
@ResponseBody
public AjaxResult uploadFile(List<MultipartFile> file, @PathVariable ("merNo") String merNo) throws Exception
{
try
{
.....
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
- 如果@RequestMapping中表示为”item/{id}”,id和形参名称一致,@PathVariable不用指定名称。如果不一致,例如”item/{ItemId}”则需要指定名称@PathVariable(“itemId”)。
- 因此原代码中的参数@RequestMapping(value = "/findUserByEmployeeNumber/{EmployeeNumber}中{EmployeeNumber}变量名需要和@PathVariable @Valid String employeeNumber中一样
修改办法:
1、方法一:修改PostMapping,带参数
@PostMapping("/common/upload1/{merNo}")
@ResponseBody
public AjaxResult uploadFile(List<MultipartFile> file, @PathVariable ("merNo") String merNo) throws Exception
{
try
{
.....
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
2、方法二:将 @PathVariable 修改为@RequestParam
/** * 通用上传请求 */
@PostMapping("/common/upload1")
@ResponseBody
public AjaxResult uploadFile(List<MultipartFile> file, @RequestParam("merNo") String merNo) throws Exception
{
try
{
....
AjaxResult ajax = AjaxResult.success();
/* ajax.put("fileName", fileName); ajax.put("url", url);*/
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
注意两个区别
@PathVariable是获取url上数据的。
@RequestParam获取请求参数的(包括post表单提交)
边栏推荐
- Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
- autogluon安装,使用指南,代码
- Oracle数据库常用函数总结
- Quartz的理解
- TensorFlow: NameError: name 'input_data' is not defined
- json库的dumps()方法和loads()方法
- centos7.5 设置Mysql开机自启动
- 性能测试(03)-JDBC Request
- 想了解API接口,这一篇就够了
- Create a table in a MySQL database through Doc
猜你喜欢
随机推荐
史上最小白之《Word2vec》详解
caffe ---make all编辑出错
备战金三银四:如何成功拿到阿里offer(经历+面试题+如何准备)
性能测试(04)-表达式和业务关联-JDBC关联
15.8 the semaphore Unix environment programming chapter 15
爬虫实例,获取豆瓣上某部电影的评论
AQS同步组件-FutureTask解析和用例
Unix System Programming Chapter 15 15.2 Pipes
autogluon安装,使用指南,代码
tensor.eq() tensor.item() tensor.argmax()
TensorFlow: NameError: name 'input_data' is not defined
信息系统项目的十大管理
彻底理解工厂模式
OpenSSF's open source software risk assessment tool: Scorecards
解决1.tensorflow运行使用CPU不使用GPU 2.tensorflow环境下的GPU版本号 3.tensorflow和cuda以及cudnn版本对应问题 4.查看cuda和cudnn版本
Cluster understanding
Transformer+Embedding+Self-Attention原理详解
Oracle数据库:for update 和for update nowait的区别
1003 Emergency (25分)
numpy的ndarray取数操作