午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

原因:java.lang.IllegalStateException:找到了模糊的映射無法映射“ appController” Bean方法

瀏覽:223日期:2024-05-16 09:21:21
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解決原因:java.lang.IllegalStateException:找到了模糊的映射無法映射“ appController” Bean方法?

這是您收到的錯(cuò)誤消息:

找到模糊的映射。無法將“ appController”bean方法公共java.lang.String映射為it.besmart.controller.AppController.newClient(org.springframework.ui.ModelMap)映射到{[//new],方法= [POST],params = [], headers = [],consumes = [],produces = [],custom= []}:已經(jīng)有’appController’bean方法public java.lang.Stringit.besmart.controller.AppController.saveClient(it.besmart.models.Client,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap)映射。

它告訴您要映射多個(gè)方法來處理POSTURL /new。如果網(wǎng)絡(luò)瀏覽器POST向URL 發(fā)出請(qǐng)求,那么/new您應(yīng)該使用哪種方法處理該請(qǐng)求?

這是兩種令人反感的方法:

@RequestMapping(value = {'/new'}, method = RequestMethod.POST) public String newClient(ModelMap model){Client client = new Client();model.addAttribute('client', client);model.addAttribute('edit', false);return 'registration'; } @RequestMapping(value = {'/new'}, method = RequestMethod.POST) public String saveClient(@Valid Client client, BindingResult result, ModelMap model){if(result.hasErrors()){ return 'registration';}clientService.saveClient(client);model.addAttribute('success', 'Client' + client.getNomeClient() + 'registrato correttamente');return 'success'; }

我懷疑其中第一個(gè)是不正確的。您可能想要使用RequestMethod.GET代替RequestMethod.POST。

解決方法

早上好,我正在處理一個(gè)模棱兩可的映射,我無法解碼…我正在使用Spring mvc 4.0.6和hibernate4.3.6在tomcat中發(fā)動(dòng)戰(zhàn)爭(zhēng)時(shí)遇到此錯(cuò)誤:

ERROR [localhost-startStop-2]: Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name ’requestMappingHandlerMapping’ defined in class org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ’appController’ bean method public java.lang.String it.besmart.controller.AppController.newClient(org.springframework.ui.ModelMap)to {[//new],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already ’appController’ bean methodpublic java.lang.String it.besmart.controller.AppController.saveClient(it.besmart.models.Client,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap) mapped. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:744)Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ’appController’ bean method public java.lang.String it.besmart.controller.AppController.newClient(org.springframework.ui.ModelMap)to {[//new],org.springframework.ui.ModelMap) mapped. at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:192) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:164) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:124) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:103) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:126) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ... 25 more

我不明白為什么我會(huì)收到此錯(cuò)誤。AppController很直

package it.besmart.controller;import it.besmart.models.Client;import it.besmart.service.ClientService;import java.util.List;import java.util.Locale;import javax.validation.Valid;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.MessageSource;import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.validation.BindingResult;import org.springframework.validation.FieldError;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;@Controller@RequestMapping('/')public class AppController { @Autowired ClientService clientService; @Autowired MessageSource messageSource; @RequestMapping(value = { '/','/list' },method = RequestMethod.GET) public String listClients(ModelMap model){List<Client> clients = clientService.findAllClients();model.addAttribute('clients',clients);return 'allclients'; } @RequestMapping(value = {'/new'},method = RequestMethod.POST) public String newClient(ModelMap model){Client client = new Client();model.addAttribute('client',client);model.addAttribute('edit',false);return 'registration'; } @RequestMapping(value = {'/new'},method = RequestMethod.POST) public String saveClient(@Valid Client client,BindingResult result,ModelMap model){if(result.hasErrors()){ return 'registration';}clientService.saveClient(client);model.addAttribute('success','Client' + client.getNomeClient() + 'registrato correttamente');return 'success'; } @RequestMapping(value = { '/edit-{name}-client'},method = RequestMethod.POST) public String updateClient(@Valid Client client,ModelMap model,@PathVariable String name ){if(result.hasErrors()){ return 'registration';}if(!clientService.isClientNameUnique(client.getIdClient(),client.getNomeClient())){ FieldError idErr = new FieldError('client','name',messageSource.getMessage('non.unique.nome_client',new String[]{client.getNomeClient()},Locale.getDefault())); result.addError(idErr); return 'registration';}clientService.saveClient(client);model.addAttribute('success','Client' + client.getNomeClient() + 'aggiornato correttamente');return 'success'; } @RequestMapping(value = { '/delete-{id}-client' },method = RequestMethod.GET)public String deleteClient(@PathVariable int id){clientService.deleteClientById(id);return 'redirect:/list'; } }

ClientService.java

package it.besmart.service;import it.besmart.models.Client;import java.util.List;public interface ClientService { Client findById(int id); void saveClient(Client client); void updateClient(Client client); void deleteClientById(int id); List <Client> findAllClients(); Client findClientByName(String name); boolean isClientNameUnique(Integer id,String name);}

在我看來,這一切都是很直接的……對(duì)于這種應(yīng)用程序,我還是一個(gè)新手。

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 免费在线观看a视频 | 视频一区二区免费 | 国产高清视频在线观看 | 午夜免费观看视频 | 国产精品88| 国产精品男女 | 欧美人一级淫片a免费播放 九九热视频免费观看 | 97色在线视频 | 国产精品久久在线观看 | 一区二区三区精品视频 | 你懂的国产 | 久久久伦理 | 日韩男女视频 | 自拍偷拍日韩 | 国产日韩综合 | 中文字幕91 | www久久久久 | 丁香婷婷六月 | 高压监狱满天星在线观看 | 亚洲动态图 | 国产精品麻豆一区二区 | 青青青久久久 | 天堂av免费 | 91在线观看入口 | 欧美激情在线看 | 欧美日韩成人在线视频 | 成人碰碰 | 羞羞av | 香蕉人人精品 | 亚洲区自拍 | 亚洲无av在线中文字幕 | 一区在线播放 | 色综合天天操 | 黄色欧美网站 | 激情午夜天 | 成人免费网址 | 99久久99久久精品国产片果冰 | 免费在线你懂的 | 69精品久久久久久 | 欧美性猛交乱大交 | 69er小视频|