当前位置:网站首页>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表单提交)
边栏推荐
- 备战金三银四:如何成功拿到阿里offer(经历+面试题+如何准备)
- MNIST机器学习入门
- Netscope:神经网络结构在线可视化工具
- pip常见命令和更改源文件
- 解决1.tensorflow运行使用CPU不使用GPU 2.tensorflow环境下的GPU版本号 3.tensorflow和cuda以及cudnn版本对应问题 4.查看cuda和cudnn版本
- faster-rcnn learn
- Unix Environment Programming Chapter 15 15.7 Message Queuing
- 深度学习--生成对抗网络(Generative Adversarial Nets)
- 一键完成物联网产品注册,快速体验在线调试设备
- 数据存储:对dataframe类,使用to_csv()将中文数据写入csv文件
猜你喜欢

OpenSSF的开源软件风险评估工具:Scorecards

linux mysql操作的相关命令
![[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in](/img/a9/d6aba07e6a4e1536cd10d91f274b2e.jpg)
[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in

The complete grammar of CSDN's markdown editor

prometheus接入mysqld_exporter

Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)

MySQL索引的B+树到底有多高?

Transformer+Embedding+Self-Attention原理详解

深度学习--生成对抗网络(Generative Adversarial Nets)

Cpolar内网穿透的面板功能介绍
随机推荐
Jmeter BeanShell post processor
Probably 95% of the people are still making PyTorch mistakes
【原创】JPA中@PrePersist和@PreUpdate的用法
Cpolar内网穿透的面板功能介绍
VBA实战(11) - 工作表(Sheet) 操作汇总
MySQL和MyEclipse的数据库连接操作
备份mongodb数据库(认证)
tensorflow和numpy对应的版本,报FutureWarning: Passing (type, 1) or ‘1type‘ as a synonym of type is deprecate
torch.stack()的官方解释,详解以及例子
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization论文阅读
String类型的字符串对象转实体类和String类型的Array转List
linux mysql操作的相关命令
Product Quantization (PQ)
通过Doc在MySQL数据库中建表
faster-rcnn learn
华为VRRP+MSTP联动接口检测实验案例
Unix Environment Programming Chapter 15 15.3 Functions popen and pclose
OneNote 教程,如何在 OneNote 中搜索和查找笔记?
相关系数计算,热力图绘制,代码实现
The torch. The stack () official explanation, explanation and example