2015-01-16 115 views
1

我休息控制器,這是由春寫的,返回404,但是當我在調試的Eclipse,我看到它來到我的方法,並返回結果,但結果仍是404彈簧安置控制器返回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(); 
    } 
} 

沒有例外或錯誤。並且請求UR是:

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

+1

它是不能夠找到控制器。什麼是cmsgateway?不應該是http:// localhost:8080/appl_war/admin/context/monitor? –

+1

在web.xml中顯示DispatcherServlet配置。檢查您的值,如果您有** / **,那麼您的網址應爲http:// localhost:8080/appl_war/admin/context/monitor –

+0

已編輯的網址。沒有cmsgateway。請求來到我的控制器方法,我可以看到。但它仍然給404 ... – Neron

回答

0

由於Danyal Sandeelo說,我認爲你必須在一流水平的RequestMapping值從「管理/語境」爲「cmsgateway /管理/背景」改變。

+0

編輯網址。沒有cmsgateway。請求來到我的控制器方法,我可以看到。但它仍然給404 ... – Neron

+1

Arrg!我也錯過了!試試這個,「/ admin/context」(注意它以/開頭) – kazbeel

1

試試這個,

確保您的配置包含@EnableWebMvc

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