2016-06-21 69 views
0

我得到這樣的:異常時要儘量達到我webfunction我春天:PageNotFound noHandlerFound警告:沒有映射的DispatcherServlet發現HTTP請求與URI名稱爲

PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI in DispatcherServlet with name 

在cotroller我:

@Controller 
@RequestMapping("/user/**") 
@Scope("request") 

和在網絡功能:

@RequestMapping(value = "test", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) 

在web.xml我添加:

<servlet-mapping> 
    <servlet-name>webApplication</servlet-name> 
    <url-pattern>/rest/*</url-pattern> 
</servlet-mapping> 

,並試圖達到ADRESS後:

http://localhost:8087/webApp-project/rest/user/test 

我得到異常:

cze 21, 2016 10:12:00 AM org.springframework.web.servlet.PageNotFound noHandlerFound 
WARNING: No mapping found for HTTP request with URI [/webApp-project/rest/user/test] in DispatcherServlet with name 'webApp' 

問題解決了通過添加:

<beans:bean class="com.capgemini.webApp.project.process.engine.authentication.UserRest" name="/rest/*"></beans:bean> 

要配置文件。請有人能告訴我爲什麼它解決了這個問題嗎?我有註解驅動的配置。

現在我想用Spring Security來保護頁面,並且遇到了問題,也許是因爲這個bean定義導致的?

回答

0

默認情況下驅動的寄存器RequestMappingHandlerMapping用於解析來自@RequestMapping註釋的映射。但它似乎沒有默認註冊,而BeanNameUrlHandlerMapping被註冊。 嘗試註冊RequestMappingHandlerMapping處理程序manualy,然後您應該查看註釋驅動的位置。 它在應用程序上下文中還是在Web應用程序上下文中。

相關問題