简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM