Some Questions and Answers for my book "Developing Enterprise Java Applications with
Spring Frameworks: An End-to-End Approach"

Q11: Listing 6.2 returns html rather than JSON. How do I fix it?

This was an issue caused by upgrading SOBA from Spring 3.1 to 3.2GA. In Spring 3.1, accepting headers was
honored by default, but in Spring 3.2, we must explicitly configure the HeaderContentNegotiationStrategy bean as
shown below to enable accepting the header specified by the client. If you downloaded the project file after Oct 25,
2013, this issue has been fixed by introducing the following changes in the soba-servlet.xml file:

                    <bean class="org.springframework.web.accept.ContentNegotiationManager">
                                                                    <entry key="json" value="application/json" />
                                                                    <entry key="xml" value="application/xml" />
                                                                    <entry key="html" value="text/html" />
                                                    class="org.springframework.web.accept.HeaderContentNegotiationStrategy" />

You can also build a Restful API to find a transaction by ID as follows:

1) Add <mvc:annotation-driven /> right after <context:annotation-config /> in soba-servlet.xml to enable MVC
2) Add the following method in (note the capital D in txID to distinguish it from the previous
html response version)

@RequestMapping(value = "/txID/{transactionId}", method = RequestMethod.GET)
public @ResponseBody BankingTx getTransactionByID(@PathVariable String transactionId) {
BankingTx transaction = bankingTxDao.findByTransactionID(transactionId);
return transaction;

Note: you also need to add import org.springframework.web.bind.annotation.ResponseBody; in to compile

3) Accordingly, in the, change "txId" to "txID"
4) Rebuild and deploy SOBA and test the as described in Chapter 6 again.

Books are my best friends ...