logo资料库

Expert Spring MVC and Web Flow 2006英文版.pdf

第1页 / 共423页
第2页 / 共423页
第3页 / 共423页
第4页 / 共423页
第5页 / 共423页
第6页 / 共423页
第7页 / 共423页
第8页 / 共423页
资料共423页,剩余部分请下载后查看
Expert Spring MVC and Web Flow
Table of Content
Chapter 1 Introduction
Chapter 2 Spring Fundamentals
Chapter 3 Spring MVC Application Architecture
Chapter 4 Jump into Spring MVC
Chapter 5 The Processing Pipeline
Chapter 6 The Controller Menagerie
Chapter 7 The View Layer
Chapter 8 Supported View Types
Chapter 9 Validation
Chapter 10 Testing Spring MVC Applications
Chapter 11 Introduction to Spring Web Flow
Chapter 12 Advanced Spring Web Flow
Appendix A Documenting Your MVC Application
Appendix B Ajax and DWR
Index
584X_Ch00_FM_FINAL 1/30/06 1:57 PM Page i Expert Spring MVC and Web Flow Seth Ladd with Darren Davison, Steven Devijver and Colin Yates
584X_Ch00_FM_FINAL 1/30/06 1:57 PM Page ii Expert Spring MVC and Web Flow Copyright © 2006 by Seth Ladd, Darren Davison, Steven Devijver, and Colin Yates All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-584-8 ISBN-10 (pbk): 1-59059-584-X Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Steve Anglin Technical Reviewers: Rob Harrop, Keith Donald Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Matt Wade Project Manager: Sofia Marchant Copy Edit Manager: Nicole LeClerc Copy Editor: Stephanie Provines Assistant Production Director: Kari Brooks-Copony Production Editor: Katie Stence Compositor and Artist: Van Winkle Design Group Proofreader: Nancy Sixsmith Indexer: Broccoli Information Management Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code section.
584X_Ch00_FM_FINAL 1/30/06 1:57 PM Page iii To my father, who brought home that old 1200-baud modem from work and kick-started this crazy journey. —Seth Ladd To Mum and Dad, for always encouraging my curiosity. And to my wife, Lisa, for being my wife. —Darren Davison For Beeky and the wriggler for putting up with the late evenings, and Bruce and Jessie for missing out on the walks. —Colin Yates For Filiz. —Steven Devijver To my wonderful wife, Keri, and our little bundle of joy, Annabelle. —Keith Donald
584X_Ch00_FM_FINAL 1/30/06 1:57 PM Page iv
584X_Ch00_FM_FINAL 1/30/06 1:57 PM Page v Contents at a Glance About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii ■ CHAPTER 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ■ CHAPTER 2 Spring Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 ■ CHAPTER 3 Spring MVC Application Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 ■ CHAPTER 4 Jump into Spring MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 ■ CHAPTER 5 The Processing Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 ■ CHAPTER 6 The Controller Menagerie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 ■ CHAPTER 7 The View Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 ■ CHAPTER 8 Supported View Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 ■ CHAPTER 9 Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 ■ CHAPTER 10 Testing Spring MVC Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 ■ CHAPTER 11 Introduction to Spring Web Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 ■ CHAPTER 12 Advanced Spring Web Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 ■ APPENDIX A Documenting Your MVC Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 ■ APPENDIX B Ajax and DWR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 v ■
584X_Ch00_FM_FINAL 1/30/06 1:57 PM Page vi
584X_Ch00_FM_FINAL 1/30/06 1:57 PM Page vii Contents About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii ■ CHAPTER 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Skipping Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 How to View This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Roadmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Target Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Sample Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Spring 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 ■ CHAPTER 2 Spring Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Inversion of Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 IoC Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Dependency Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Service Locator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Dependency Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Spring ApplicationContexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 The Return of the POJO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Impact on Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 ■ CHAPTER 3 Spring MVC Application Architecture . . . . . . . . . . . . . . . . . . . . . 21 Layers of Abstractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Layer Isolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Java Interface As Layer Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Layers in a Spring MVC Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Options: There’s More Than One Way to Do It . . . . . . . . . . . . . . . . . . . . . . . 38 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 vii
分享到:
收藏