弹簧休息控制器返回 404 [英] Spring rest controller returns 404

查看:56
本文介绍了弹簧休息控制器返回 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 rest 控制器,由 spring 编写,返回 404,但是当我通过 Eclipse 调试时,我看到它来到我的方法并返回结果但结果仍然是 404.

My rest controller ,which is written by spring, returns 404 but when I debug over Eclipse , I see that it comes to my method and returns result but result is still 404.

控制器就像:

@RestController
@RequestMapping("admin/context")
public class ApplicationAdmin {

    @Autowired
    private ApplicationContextService applicationContextService;

    @RequestMapping(value="/monitor",method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(HttpStatus.OK)
    public Response monitorContexts(){
        return this.applicationContextService.monitorContext();
    }
}

没有异常或错误.你的请求是:

There is no exception or error. And the request ur is:

http://localhost:8080/appl_war/admin/context/monitor

推荐答案

试试这个,

确保您的配置包含 @EnableWebMvc

    @Configuration
    @EnableWebMvc
    @ComponentScan(basePackages = {"bla.bla.bla"})
    public class Configuration{

这篇关于弹簧休息控制器返回 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆