【发布时间】:2016-03-25 14:40:03
【问题描述】:
@Controller("/UserAction")
@RequestMapping("/greet.json")
public class UserAction extends BaseAction {
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public void hello(HttpServletRequest request,HttpServletResponse response) {
System.out.println("a");
}
@RequestMapping(value = "/word", method = RequestMethod.GET)
public void word(HttpServletRequest request,HttpServletResponse response) {
System.out.println("123123@@@");
}
}
当我看http://localhost:8080/ProjectName/greet.json/hello 和http://localhost:8080/ProjectName/greet.json/word 无法执行 syso 方法
将“{[/greet.json],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}”映射到 public void cn.elfsoft .controller.UserAction.hello(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 08:33:38,488 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (org.springframework.beans.factory.support.DefaultSingletonBeanRegistry:433) - 销毁 org.springframework.beans.factory.support.DefaultListableBeanFactory@ 中的单例4eed49c9:定义bean [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context .annotation.internalPersistenceAnnotationProcessor,AnswerAction,FileResourceAction,SendMessageAction,SubjectAction,userAction,videoAction,baseDAO,FileResource,QuestionDao,SubjectDao,videoDao,FileResourceService,QuestionService,SubjectService,UserService,videoService,org.springframework.web.servlet.view.InternalResourceViewResolver#0 ,org.springframework.web.servlet.mvc.method.an notation.RequestMappingHandlerMapping#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.aop.config.internalAutoProxyCreator,cn。 elfsoft.log.LogAdvice#0,dataSource,org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor#0,sessionFactory,jdbcTemplate,txManager,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor。 TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,businessService,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0];工厂层次结构的根 08:33:38,490 错误 [org.springframework.web.servlet.DispatcherServlet] (org.springframework.web.servlet.FrameworkServlet:460) - 上下文初始化失败 org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/web-config.xml] 中定义名称为“org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0”的 bean 创建错误: init 方法调用失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法映射“userAction”bean 方法 公共无效 cn.elfsoft.controller.UserAction.word(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) to {[/greet.json],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: 已经有 'userAction' bean 方法 public void cn.elfsoft.controller.UserAction.hello(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 映射。
【问题讨论】:
标签: spring-mvc request-mapping