0

I have this method:

@RequestMapping( value = DetailedMetaDataController.RESOURCE_PATH + ".xml", headers = "Accept=application/json" )
public void exportXml( @RequestBody JSONObject json ) throws IOException
{
    String responseString = JacksonUtils.toXmlAsString();
}

The responseString is a XML String. The AJAX request is a post because I send large amount of data, but the AJAX always returns error.

I need a simple Window with which to save the String as a xml file.

1
  • 1
    Can you post the error, status code? Commented Jul 16, 2013 at 19:25

2 Answers 2

2

Annotate with @Produces(MediaType.APPLICATION_XML) and make sure your request uses application/xml as part of an Accept header.

Sign up to request clarification or add additional context in comments.

5 Comments

I don't think this is JAX-RS.
JAX-RS is part of JRE6 core, and Jackson is designed to be used with JAX-RS, so I assumed (perhaps incorrectly) that this was a jax-rs project.
With @RequestMapping, it's a Spring MVC project, which also uses jackson. OP might want to consider using JSX-RS.
Can you help me with a fix for a Spring MVC project ?. I have the string ready, just cant figure out how to send it as a xml file :(
You'll get no help from me with Spring MVC. Sorry. You might want to add Spring MVC to your tag list.
1

You can wrap the data in a bean annotated with @javax.xml.bind.annotation.XmlRootElement, field with @javax.xml.bind.annotation.XmlElement and change method signature from public void to public @org.springframework.web.bind.annotation.ResponseBody BeanClassName, returning corresponding BeanClassName instance. Also remember about <mvc:annotation-driven /> in your Spring XML config file.

For more info see this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.