首页 > 解决方案 > Java Spring @GetMapping not found

问题描述

I write two functions @GetMapping in one class. Function getProcessImage is working but Function hello is not working.

NOT FOUND 404

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);
}

标签: javaspringspring-bootrest

解决方案


您需要将 getMapping 更改为 /image (即删除 / ),或者您需要在 url 路径中添加 image/ 。我建议您在代码中将 / 删除为 /image


推荐阅读