maven - 406 Not Acceptable Spring Rest WS -
I am writing a spring balance to get feedback as XML. Below are my classes and palm file. I
I get an HTTP 406 error in execution as a service:
http: // localhost: 8080 / SpringRestExample /
However, I am returning the JSON response when executing
http: // localhost: 8080 / SpringRestExample / Rest / emp / dummy.json
please give advice
pom.xml
& lt; Dependency & gt; & Lt; Group & gt; Org.codehaus.jackson & lt; / Group & gt; & Lt; ArtifactId & gt; Jackson-Map Maker-ASL & lt; / ArtifactId> & Lt; Version & gt; $ {Jackson.version} & lt; / Edition & gt; & Lt; / Dependencies & gt; Employee Controller: @RequestMapping (value = "/ rest / AMP / dummy", method = RequestMethod.GET, produces = {" App / XML "}) Public @ResponseBody Employee Received Dummy EmpireXML () {logger.info (" GetDummyEmployee Start "); Employee employee = new employee (); Emp.setId (9999); Emp.setName ("dummy"); Emp.setCreatedDate (new date ()); EmpData.put (99 99, AMP); Return EMP; }
app- context.xml
& Lt; Reference: component-scan base-package = "com.skanda.spring.controller" /> & Lt; Beans: Bean id = "Content chat manager" class = "org.springframework.web.accept.ContentNegotiationManagerFactoryBean" & gt; & Lt; Beans: Property Name = "Particle Extension" Value = "True" /> & Lt; Beans: property name = "partypalmter" value = "true" /> & lt; Beans: Properties name = "parameterName" value = "mediaType" /> & Lt; Beans: Attribute name = "UndiscoveredAccellation header" value = "true" /> & Lt; Beans: Property Name = "Usage" Value = "Wrong" /> & Lt; Beans: Properties Name = "Default Content Type" value = "App / JSON" /> & Lt; Beans: property name = "media type" & gt; & Lt; Bean: map & gt; & Lt; Beans: Entry key = "JSON" value = "App / JSON" /> & Lt; Beans: entry key = "xml" value = "application / xml" /> & Lt; / Bean: map & gt; & Lt; / Beans: property & gt; & Lt; / Bean: beans & gt; Employee: Public-class employee serializable {Private constant last long serial VERSIONUID = 7788619177798333712L; Private Ent ID; The name of the private string; Personal date created date; Public int getId () {return ID; } Public Zero setId (int id) {this.id = id; } Public string getName () {return name; } Public Zero Setname (string name) {this.name = name; } @JasonSerialize (= Date using serializer.class) while getting public date () {Date created on return; } Public Zero Set Credit Date (date date) {this.createdDate = createdDate; }}
406 means that the server is unable to respond to the content Check the type the customer asked to accept the title of your HTTP request, and make sure there is an application / xml included
Maybe there is text / xml in it, and this is what you @RequestMapping
should be used in the annotation's output
attribute. BTW, you should use the constant in org.springframework.http.MediaType
instead of coding instead of string.
Comments
Post a Comment