spring mvc - HttpMediaTypeNotAcceptableException: Could not find acceptable representation. When with special url -


    @requestmapping(value = "/servers/{domain}", method = requestmethod.get)     public server getmailserver(@pathvariable("domain") string domain)      server server = null;     try {         server = getserverbydomain(domain);     }     catch(exception e){      }      return server;     } 

when call "http://localhost:8080/server/hotmail.com" httpclient method,the value of variable domain "hotmail", not "hotmail.com".and got error: httpmediatypenotacceptableexception: not find acceptable representation.

but if call "http://localhost:8080/server/hotmail", works well.

i hope can see causing issue.

this might same issue had (and guy: https://stick2code.blogspot.co.at/2014/03/solved-orgspringframeworkwebhttpmediaty.html)

my service offers operations on files, i.e., /files/check/foo.txt

i got httpmediatypenotacceptableexception , rest handler never called.

the problem is, spring has feature tries detect requested content type path extension. .com mean com file. (see http://docs.spring.io/spring/docs/4.3.3.release/spring-framework-reference/htmlsingle/#mvc-config-content-negotiation , http://docs.spring.io/spring/docs/4.3.3.release/spring-framework-reference/htmlsingle/#mvc-config-path-matching)

my minimal @config fix:

@configuration @enablewebmvc public class pathdispatchconfig extends webmvcconfigureradapter {      @override     public void configurepathmatch(pathmatchconfigurer configurer) {         configurer.setusesuffixpatternmatch(false);         configurer.setuseregisteredsuffixpatternmatch(false);     }      @override     public void configurecontentnegotiation(contentnegotiationconfigurer configurer) {         configurer.favorpathextension(false);     } } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -