java - How to solve spring mvc mapping -


i have 2 controllers first 1 was:

    @controller("/similarsearch") public class similarsearchcontroller {    @autowired   similarsearchservice similarsearchservice;    @requestmapping(method = requestmethod.get,produces = "application/json; charset=utf-8")   @responsebody   public string loadsimilarsearchphrases(httpservletrequest request,                                          @requestparam(value = "q", required = true, defaultvalue = "") final string query){     httpsession session = request.getsession();     list<list<similarlink>> responsemain = (list<list<similarlink>>) session.getattribute("responsemain");     map<string, list<string>> result = similarsearchservice.getsimilarsearchphrases(responsemain,query);     return new jsonserializer().exclude(jsonhelper.standard_exclude).include("*").serialize(result);   } } 

and worked perfectly, when accessed localhost:0000/similarsearch/ returned me needed json. when added controller

@controller("wiki") public class wikicontroller {    @autowired   searchservice searchservice;    @suppresswarnings("unchecked")   @requestmapping(method = requestmethod.get,produces = "application/json; charset=utf-8")   @responsebody   public string loadwikiinfo(httpservletrequest request,                              @requestparam(value = "q", required = true, defaultvalue = "") final string query){     httpsession session = request.getsession();     list<list<similarlink>> responsemain = (list<list<similarlink>>) session.getattribute("responsemain");     wikiinfolocal wikiinfo = searchservice.getwikiinfo(responsemain,query);     return new jsonserializer().exclude(jsonhelper.standard_exclude).include("*").serialize(wikiinfo);   } } 

i received

java.lang.illegalstateexception: ambiguous mapping found. cannot map '/similarsearch' bean method

public java.lang.string org.izsearch.controllers.similarsearchcontroller.loadsimilarsearchphrases(javax.servlet.http.httpservletrequest,java.lang.string) {[],methods=[get],params=[],headers=[],consumes=[],produces=[application/json;charset=utf-8],custom=[]}: there 'wiki' bean method 

and can't use no 1 of these controller.

it should work described, can see in logs registered endpoints. can see if these controllers registered or not (or how). can try define endpoint not in @controller @ @requestmapping annotation param value see here:

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/bind/annotation/requestmapping.html#value--

i hope resolve issue!


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -