3. A Few Examples
TV Mobile
+ + =
Live stream, shop as you
watch
Mobile
+ =
Want this, alert me when
near shop
Product
Product
Checkout
Location
POS
+ =
Not available in store,
deliver to home
Product Checkout
17. Another Controller — this Time for a Web Service
@Controller
public class CartController extends BaseController
{
@Resource(name = "cartFacade")
private CartFacade cartFacade;
!
@RequestMapping(value = "/entry", method = RequestMethod.POST)
@ResponseBody
public CartModificationData addToCart(@RequestParam(required = true) String code,
@RequestParam(required = false, defaultValue = "1") long qty)
throws CommerceCartModificationException
{
return cartFacade.addToCart(code, qty);
}
!
}
18. Marshal Response DTOs to XML/JSON
<!-- from springmvc-servlet.xml -->
!
<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<bean parent="resolverXStreamJSONConverter"/>
<bean parent="resolverXStreamXmlConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>