[英]Handler mapping issue after integrating with spring security
I have two mapping patter /userdetails one for get request and one for post request. 我有两个映射模式/ userdetails,一个用于获取请求,一个用于发布请求。
It was working fine till I integrated Spring authorization into my project. 直到我将Spring授权集成到我的项目中,一切都很好。 Now I am getting below error any idea why this is happening?
现在我在错误下面知道为什么会这样吗?
My Two mappings are like this. 我的两个映射是这样的。
@RequestMapping(value = "/userdetails* ", method = RequestMethod.GET)
@RequestMapping(value = "/userdetails*", method = RequestMethod.POST)
Please suggest any reason for this error. 请提出任何导致此错误的原因。
Caused by: java.lang.IllegalStateException: Cannot map handler 'LoginController' to URL path [/userdetails]: There is already handler of type [class com.sample.user.controller.MyController] mapped.
at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:390)
at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)
at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:117)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:396)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
I faced similar kind of problem. 我遇到了类似的问题。 I have defined the controller class with "@Controller" and also in the Spring-config.xml file as a bean and have injected the dependencies.
我已经使用“ @Controller”以及在Spring-config.xml文件中将控制器类定义为bean,并注入了依赖项。
This was causing the problem. 这是造成问题的原因。 @Controller is defining the bean and again, the bean defined in the xml file is redefining the dependencies.
@Controller定义了bean,再次,在xml文件中定义的bean重新定义了依赖关系。 I tried autowiring the dependency and removed it as a bean from the xml file.
我尝试自动装配依赖项,并将其作为Bean从xml文件中删除。 Then it worked.
然后它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.