java - Java Spring @GetMapping not found
问题描述
I write two functions @GetMapping in one class. Function getProcessImage is working but Function hello is not working. It is not found 404.
@GetMapping(value = "/{processInsID}/{containerId}")
public ServiceResponse<String> getProcessImage(@PathVariable("processInsID") long procInstId,
@PathVariable("containerId") String containerId) {
AuthenticationInfo bpmAuthenInfo = new AuthenticationInfo(env.getProperty("jbpm.url"),
env.getProperty("jbpm.username"), env.getProperty("jbpm.password"), "");
String result = jbpmService.getImageProcessInProgess(bpmAuthenInfo, containerId, procInstId);
try {
return new ServiceResponse<String>(Constant.ServiceResponse.CODE_SUCCESS,
Constant.ServiceResponse.MSG_SUCCESS, result);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
return new ServiceResponse<String>(Constant.ServiceResponse.CODE_ERROR, e.getMessage(), null);
}
}
@GetMapping(value = "/image/")
public ServiceResponse<String> hello() {
return new ServiceResponse<String>(Constant.ServiceResponse.CODE_ERROR,"okok", null);
}
解决方案
您需要将 getMapping 更改为 /image (即删除 / ),或者您需要在 url 路径中添加 image/ 。我建议您在代码中将 / 删除为 /image
推荐阅读
- typescript - TypeScript:在编译时使用枚举作为接口/对象键的过滤器
- swiftui - SwiftUI List NavigationLink 初始化所有细节视图
- c# - c# selenium中如何验证单列值是否按webtable的字母顺序排列
- reactjs - 您可能混淆了默认导入和命名导入:仅使用默认导入
- r - 如何在 R boxplot 中强制 y 轴以科学计数法返回值
- flutter - 如何在 Flutter 中动态调整 BottomSheet 的高度?
- python - 在 Python 中将 FASTA 对齐文件拆分为所有可能的对齐对
- swagger - 如何定义openAPI参数组合?
- visual-studio-code - 如何重新定位 VS Code 的弹出式建议框?
- java - FindBugs - 已装箱的值被取消装箱,然后立即重新装箱