PageNotFound noHandlerFound警告:在DispatcherServlet中找不到带有URI的HTTP请求的映射名称

时间:2016-06-21 08:17:02

标签: java spring security web web-config

我得到了这个:异常何时尝试触及我的网络功能我是春天:

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>

试图达到地址后:

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定义引起的?

1 个答案:

答案 0 :(得分:0)

默认驱动寄存器RequestMappingHandlerMapping,用于解析来自@RequestMapping注释的映射。但它似乎默认情况下没有注册,而是注册了BeanNameUrlHandlerMapping。 尝试手动注册RequestMappingHandlerMapping处理程序然后你应该看看你在哪里放置了注释驱动。 它是在应用程序上下文中还是在Web应用程序上下文中。

相关问题