@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方法
Mapped" {[/ greet.json],methods = [],params = [],headers = [],consume = [],produce = [],custom = []}" on 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,数据源,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 ERROR [org.springframework.web.servlet.DispatcherServlet](org.springframework.web.servlet.FrameworkServlet:460) - 上下文初始化失败 org.springframework.beans.factory.BeanCreationException:使用名称' org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0'创建bean时出错。在ServletContext资源[/WEB-INF/web-config.xml]中定义:init方法的调用失败;嵌套异常是java.lang.IllegalStateException:找到了不明确的映射。无法映射' userAction'豆方法 public void cn.elfsoft.controller.UserAction.word(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) to {[/greet.json],methods = [],params = [],headers = [],consume = [],produce = [],custom = []}:已有' userAction&#39 ;豆方法 public void cn.elfsoft.controller.UserAction.hello(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)已映射。
答案 0 :(得分:0)
我认为你有2个注释混淆了你的操作,试着只使用它:
@Controller
public class UserAction extends BaseAction {
@RequestMapping(value = "/greet.json/hello", method = RequestMethod.GET)
public void hello(HttpServletRequest request,HttpServletResponse response) {
System.out.println("a");
}
@RequestMapping(value = "/greet.json/word", method = RequestMethod.GET)
public void word(HttpServletRequest request,HttpServletResponse response) {
System.out.println("123123@@@");
}
如果你想使用你的控制器的通用路径添加 @Controller(" /文件版本&#34)
以后用
的每个方法@RequestMapping("/specificEndPoint")