Error message:
Severe: Context initialization failed
Org. Springframework. Beans. Factory. BeanCreationException: Error creating bean with the name 'org. Springframework. Web. Servlet. MVC) method. The annotation. The RequestMappingHandlerMapping' : the Invocation of the init method failed; Nested exception is Java. Lang. An IllegalStateException: Ambiguous mapping. Always map 'seckillController method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. Detail (Java. Lang. Long, org. Springframework. UI, the Model)
To {[], the methods=[GET]} : There is already a 'seckillController' bean method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. List (org. Springframework. UI. Model) mapped.
The at org. Springframework. Beans. Factory. Support. AbstractAutowireCapableBeanFactory. InitializeBean (AbstractAutowireCapableBeanFactory. Java: 1578)
The at org. Springframework. Beans. Factory. Support. AbstractAutowireCapableBeanFactory. DoCreateBean (AbstractAutowireCapableBeanFactory. Java: 545)
The at org. Springframework. Beans. Factory. Support. AbstractAutowireCapableBeanFactory. CreateBean (AbstractAutowireCapableBeanFactory. Java: 482)
The at org. Springframework. Beans. Factory. Support. AbstractBeanFactory $1. GetObject (AbstractBeanFactory. Java: 306)
.
Under Caused by: Java. Lang. An IllegalStateException: Ambiguous mapping. Always map 'seckillController method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. Detail (Java. Lang. Long, org. Springframework. UI, the Model)
To {[], the methods=[GET]} : There is already a 'seckillController' bean method
Public Java. Lang. String org. Buxingshi. Seckill. Controller. SeckillController. List (org. Springframework. UI. Model) mapped.
The at org. Springframework. Web. Servlet. Handler. AbstractHandlerMethodMapping $MappingRegistry. AssertUniqueMethodMapping (AbstractHandlerMethodMapping. Java: 567)...
The controller class:
@ Controller
@ RequestMapping (name="/seckill")
Public class SeckillController {
Private static Logger Logger=LoggerFactory. GetLogger (SeckillController. Class);
Private SeckillService SeckillService;
Public SeckillService getSeckillService () {
Return seckillService;
}
The @autowired
Public void setSeckillService (SeckillService SeckillService) {
Enclosing seckillService=seckillService;
}
@ RequestMapping (name="/list", method=RequestMethod. GET)
Public String list (Model Model) {
List
Model. The addAttribute (" list ", a list);
Return "a list";
}
@ RequestMapping (name="/{seckillId}/detail", method=RequestMethod. GET)
Public String detail (@ PathVariable (" seckillId ") Long seckillId, Model Model) {
If (seckillId==null) {
Return "a list";
}
Seckill Seckill=seckillService. GetById (seckillId);
If (seckill==null) {
The return of "forword:/seckill/list";
}
Model. The addAttribute (" seckill "seckill);
Return "detail";
}
Spring - web. XML configuration:
Pom. The XML depends on the following: