Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c47edd15
Commit
c47edd15
authored
Feb 26, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Update instructions on how to use JAXB as XML renderer"
Closes gh-16005
parent
221ff8d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
howto.adoc
...oot-project/spring-boot-docs/src/main/asciidoc/howto.adoc
+11
-13
No files found.
spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
c47edd15
...
...
@@ -1154,15 +1154,9 @@ tend to send accept headers that prefer XML.
[[howto-write-an-xml-rest-service]]
=== Write an XML REST Service
If you have the Jackson XML extension (`jackson-dataformat-xml`) o
r JAXB o
n the classpath, you
If you have the Jackson XML extension (`jackson-dataformat-xml`) on the classpath, you
can use it to render XML responses. The previous example that we used for JSON would
work.
NOTE: To get the server to render XML instead of JSON, you might have to send an
`Accept: text/xml` header (or use a browser).
==== Jackson XML
To use the Jackson XML renderer, add the following dependency to your project:
work. To use the Jackson XML renderer, add the following dependency to your project:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
...
...
@@ -1172,10 +1166,9 @@ To use the Jackson XML renderer, add the following dependency to your project:
</dependency>
----
==== JAXB
If Jackson's XML extension is not available, JAXB is tried next,
with the additional requirement of having `MyThing` annotated as
`@XmlRootElement`, as shown in the following example:
If Jackson's XML extension is not available and JAXB is available, XML can be rendered
with the additional requirement of having `MyThing` annotated as `@XmlRootElement`, as
shown in the following example:
[source,java,indent=0,subs="verbatim,quotes,attributes"]
----
...
...
@@ -1186,7 +1179,8 @@ with the additional requirement of having `MyThing` annotated as
}
----
To use JAXB as XML renderer, add the following dependency to your project:
JAXB is only available out of the box with Java 8. If you're using a more recent java
generation, add the following dependency to your project:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
...
...
@@ -1196,6 +1190,10 @@ To use JAXB as XML renderer, add the following dependency to your project:
</dependency>
----
NOTE: To get the server to render XML instead of JSON, you might have to send an
`Accept: text/xml` header (or use a browser).
[[howto-customize-the-jackson-objectmapper]]
=== Customize the Jackson ObjectMapper
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment