Traditional Culture Encyclopedia - Almanac inquiry - Lightweight Java EE Enterprise Application (3rd Edition) ——Struts 2+Spring 3+Hibernate Integrated Development Directory

Lightweight Java EE Enterprise Application (3rd Edition) ——Struts 2+Spring 3+Hibernate Integrated Development Directory

Chapter 1 Java EE application and development environment 1

1. 1 Java EE application overview II

1. 1. 1 hierarchical model of Java EE application II

1.1.2 Component 3 of Java EE application

1.1.3 structure and advantages of Java ee application 4

1. 1.4 universal Java EE server 4

1.2 lightweight Java EE application related technologies 5

1.2. 1 JSP, Servlet 3.0, JavaBean and Alternative Technologies 5

1.2.2 Struts 2.2 and alternative technologies 5

1.2.3 dormancy 3.6 and alternative technology 6

1.2.4 spring 3.0 and alternative technology 6

Download and install 1.3 Tomcat 7.

1.3. 1 Install Tomcat Server 8.

1.3.2 Configure Tomcat service port 9.

1.3.3 Enter the console 10.

1.3.4 Deploying Web Applications 12

1.3.5 Configure the data source of Tomcat 13.

Installation and use of 1.4 Eclipse 15

1. 4. 1 Download and install Eclipse 15.

1.4.2 Install Eclipse plug-in online 15

1.4.3 Install the plug-in from the local compressed package 17.

1.4.4 Install Eclipse plug-in manually 17.

1.4.5 Developing Java EE application with Eclipse 18

1.4.6 Import Eclipse Project 2 1

1.4.7 Import Non-Eclipse Project 22

1.5 installation and use of ant23

Download and install 1.5. 1 Ant 23.

1.5.2 using Ant tools 24

1.5.3 define the generation file 25

1.5.4 the task of ant 29

The cooperative development of 1.6 and CVS 3 1

1.6. 1 Install CVS server 32

1.6.2 Configure CVS Repository 34

1.6.3 Install CVS client 35

1.6.4 Publish the project to the server 35

1.6.5 Download item 37 from the server

1.6.6 Synchronize (update) local files 38

1.6.7 Submit modification 39

1.6.8 Add files and directories 39

1.6.9 Delete files and directories 40

1. 6. 10 View file version change 4 1

1.6. 1 1 Extract the contents of the previous version of file 42.

1.6. 12 was restarted from the previous version 42.

1.6. 13 Create a label 43

1.6. 14 Create a branch 43

1.6. 15 develops along branch 44.

1.6. 16 uses Eclipse as the CVS client 44.

1.7 Summary of this chapter 46

Chapter 2 JSP/Servlet and Related Technologies Detailed Explanation 47

2. 1 Web application and web.xml file 48

2. 1. 1 building a Web application 48

2. 1.2 configuration descriptor web.xml 49

2.2 the basic principle of JSP 50

2.3 JSP notes 54

2.4 JSP statement 54

2.5 output JSP expression 56

2.6 JSP script 56

2.7 JSP three compilation instructions 59

Description on page 59

2.7.2 includes instruction 63.

2.8 JSP 7 operating instructions 63

Forward instruction 64

2.8.2 including instructions 66

2.8.3 useBean, setProperty, getProperty instructions 67

Plug-in description 70

Parameter instruction 70

2.9 9 9 Built-in Objects in Scripts 70

2.9. 1 application object 72

Configuration object 77

Exception object 79

2.9.4 Output object 8 1

Page context object 82

Request object 84

2.9.7 Response Object 9 1

2.9.8 Session Object 95

2. Introduction to10 servlet 97

2. 10. 1 Servlet development 97

2. 10.2 Servlet configuration 99

2. 10.3 JSP/Servlet life cycle

2. 10.4 Load Servlet 10 1

2. 10.5 Access the configuration parameters of Servlet 102.

2. 10.6 using Servlet as controller 104

2. 1 1 JSP 2 custom label 108

2. 1 1. 1 Develop a custom label class 109.

2. 1 1.2 Create a TLD file 109.

2. 1 1.3 Use the tag library 1 10.

2. 1 1.4 Label with the attribute11

2. 1 1.5 label, the label body is 1 15.

2. 1 1.6 Tags with page fragments as attributes 1 17

2. 1 1.7 dynamic attribute label 1 18

2./introduction of kloc-0/2 filter 120

2. 12. 1 Create filter class 120

2. 12.2 Configure the filter 12 1.

2. 12.3 realize website pseudo static 125 by URL rewriting.

2./introduction of kloc-0/3 listener 126

2. 13. 1 implement listener class 127

2. 13.2 Configure Listener 128

2. 13.3 using ServletContextAttribute- listener 129

2. 13.4 using ServletRequestListener and servletrequestattributelistener130

2. 13.5 uses HttpSessionListener and HTTP session property listener 13 1.

2. 14 JSP 2 features 136

2. 14. 1 configure JSP properties 136

2. 14.2 expression language 138

2. 14.3 Tag file support 146.

2. 15 Servlet 3.0 new features 148

Servlet 3.0 2. 15. 1 comments 148

2.15.2 Web module support of servlet 3.0 149.

2.15.3 asynchronous processing provided by servlet 3.0 15 1

2. 15.4 Improved Servlet API 154

2. 16 Overview of this chapter 156

Chapter 3 Basic Usage of Struts 2 157

3.1Overview of MVC Thought 158

3. 1. 1 traditional model 1 and model 2 158

3. 1.2 MVC thought and its advantages 159

3.2 Struts 2 download and installation 160

3.2. 1 Add Struts 2 support for Web applications 160.

3.2.2 Use Struts 2 16 1 in Eclipse.

3.2.3 Add login processing 162.

3.3 Struts 2 process 165

3.3. 1 Struts 2 application development steps 165

3.3.2 Processing of Scaffold 2 166

3.4 General configuration of pillars 2 167

3.4. 1 constant configuration 167

3.4.2 contains other configuration files 173.

3.5 Implementation Action 174

3.5. 1 action interface and action support base class 175.

3.5.2 Operation Access Servlet API 177

3.5.3 Operation directly accesses Servlet API 179.

3.5.4 Access Servlet API 18 1 using ServletActionContext.

3.6 Configuration Operation 182

3.6. 1 package and namespace 182

3.6.2 Basic Configuration of Action 185

3.6.3 Dial 186 using dynamic operation method.

3.6.4 Specify method attributes and use the wildcard 188.

3.6.5 Configure the default operation 194.

3.6.6 Configure the default processing class of the action 194.

3.7 Configuration Processing Result 195

3.7. 1 Understanding the processing result 195

Configuration result 195

3.7.3 Struts 2 supports the result type 197.

3.7.4 Clear text result type 198

3.7.5 Redirect Result Type 200

3.7.6 Redirect result type 20 1

Dynamic results 202

3.7.8 The value of the action attribute determines the physical view resource 202.

3.7.9 Global Outcomes 204

3.7. 10 uses the pre-result listener 205

3.8 Configure Struts 2 exception handling 206

3.8. 1 Struts 2 exception handling mechanism 207

3.8.2 declarative exception capture 208

3.8.3 Output abnormal information 2 10

3.9 Contract plug-ins and "Contract" support 2 1 1.

3.9. 1 Action Search and Mapping Convention211

3.9.2 Draw the result 2 14 as agreed.

3.9.3 Agreement on Action Chain 2 16

3.9.4 Automatically reload the mapping 2 18

3.9.5 The correlation constant of conventional plug-ins is 2 18.

3.9.6 Notes on Conventional Plug-ins 2 19

3. 10 Internationalization using Struts 2 19

3. 10. 1 Struts 2 Load global resource file 2 19

3. 10.2 access internationalization message 220

3. 10.3 output internationalization message with placeholder 222.

3. 10.4 Method of loading resource files 224

3. 10.5 Order of loading resource files 228

3. 1 1 Use Struts 2 tag library 228

3.11.1struts 2 tag library overview 228

3. 1 1.2 using Struts 2 tag 229

OGNL expression language 230 of 3.11.3 struts 2

Set operation 232 in 3.11.4 ognl.

3. 1 1.5 accessing static member 233

3. 1 1.6λ(? Expression 234

3. 1 1.7 control label 234

3. 1 1.8 data label 244

3. 1 1.9 theme and template 254

3. 1 1. 10 custom theme 256

3.11.11form label 257

3. 1 1. 12 Non-Form Label 270

3. 12 Summary of this chapter 273

In chapter 4, Struts 2 274 is deeply used.

4. 1 Explain the type conversion of Struts 2 in detail 275

4. 1. 1 Struts 2 built-in type converter 276.

4. 1.2 Type conversion based on OGNL 276

4.2.3 Specify the type of collection elements 279

4. 1.4 custom type converter 280

4. 1.5 registered type converter 283

4. 1.6 custom type converter based on Struts 2 284

4. 1.7 processing set 285

4. Error handling in1.8 type conversion 288

4.2 Use Struts 2 for input verification 293

4.2. 1 Write verification rule file 294

4.2.2 International Prompt Information 296

4.2.3 Using Client Authentication 298

4.2.4 Configuration Style of Field Inspector 300

4.2.5 Configuration mode of off-site inspector 30 1

The short circuit checker 302

4.2.7 search rules in mcrc304

4.2.8 Check sequence and short circuit 305

4.2.9 Built-in Checker 306

4.2. 10 Input Verification Based on Note 3 16

4.2. 1 1 Manual input verification 3 18.

4.3 Use Struts 2 to control file uploading 322

4.3. 1 Struts 2 file upload 322

4.3.2 Operation of uploading files 322.

4.3.3 Configuration File Uploading Operation 325

4.3.4 Manual File Filtering 326

4.3.5 Interceptor implements file filtering 328

Output error prompt 329

4.3.7 Constant configuration of file uploading 330

4.4 Use Struts 2 to control file download 330

4.4. 1 file download operation 330

Configuration operation 332

4.4.3 Authorization control before downloading 332

4.5 Explain in detail the interception mechanism of Struts 2.334

4.5. Functions of Interceptor in1Struts2334

4.5.2 Struts 2 built-in interceptor 334

4.5.3 Configuring Interceptor 336

Using interceptor 338

4.5.5 Configure the default interceptor 338

4.5.6 Implementing Interceptor Class 340

Using interceptor 342

4.5.8 Interceptor of Interception Method 343

4.5.9 Execution sequence of interceptors 345

4.5. 10 Listener for intercepting result 347

4.5. 1 1 Override the parameter 348 of a specific interceptor in the interceptor stack.

4.5. 12 Using Interceptors to Complete Access Control 349

4.6 Ajax using Struts 2 supports 35 1.

4.6. 1 Implemented Ajax 352 for stream type results.

Basic knowledge of JSON 354

Implementing action logic 356

4.6.4 json plug-ins and json type results 357

4.6.5 Realizing JSP Page 359

4.7 Overview of this chapter 36 1

Chapter 5 Basic Usage of Hibernate 362

5. 1 ORM and Hibernate 363

5. 1. 1 object/relational database mapping (ORM)363

5. 1.2 basic mapping mode 364

5. 1.3 Introduction to popular ORM frameworks 365

5. 1.4 Hibernation Overview 366

5.2 Introduction to Hibernate 366

5.2. 1 Hibernate download and installation 366

Database operation of Hibernate 367

5.2.3 Using Hibernate 37 1

5.3 Sleep Architecture 376

5.4 In-depth understanding of Hibernate's configuration file 377

Create configuration object 377

Hibernate.properties file and hibernate.cfg.xml file 380.

5.4.3 JDBC connection properties 380

5.4.4 Database Dialect 38 1

5.4.5 Connection properties of JNDI data sources 382

Dormant transaction attribute 382

5.4.7 L2 Cache Related Attributes 383

5.4.8 External Connection Grab Attribute 383

5.4.9 Other Common Configuration Attributes 383

5.5 Deep understanding of persistent objects 384

5.5. 1 requirements for persistent categories 384

5.5.2 Status of Persistent Objects 385

5.5.3 Method of Changing Persistent Object State 386

5.6 Deep Hibernation Mapping File 389

Mapping file structure 389

5.6.2 Mapping Primary Key 392

5.6.3 Mapping Common Attributes 393

5.6.4 Mapping Set Attribute 398

5.6.5 Performance Analysis of Set Attribute 407

5.6.6 Ordered Set Mapping 409

5.6.7 Mapping database object 4 1 1

5.7 Mapping Component Attribute 4 14

5.7. 1 Component attribute is set to 4 16.

5.7.2 The element of the set attribute is component 4 18.

5.7.3 Component 420 as Map Index

5.7.4 Component 422 as Composite Primary Key

5.7.5 Multiple columns as joint primary key 425

5.8 Use JPA comments to mark the entity 426.

5.8. 1 added JPA annotation support 426.

5.8.2 Notes? Or an XML mapping file 429.

5.9 Overview of this chapter 429

Chapter 6 In-depth use of Hibernate 430

6. Association mapping of1hibernate431

6. 1. 1 unidirectional N- 1 association 43 1

6. 1.2 One-way 1- 1 Association 436

6. 1.3 One-way 1-n association 439

6. 1.4 One-way N-N correlation 443

6. 1.5 bidirectional 1-N association 443

6. 1.6 Bidirectional N-N correlation 448

6. 1.7 Bidirectional 1- 1 Association 450

6. 1.8 Associated Entities Included in Component Attributes 453

6. 1.9 Relationship based on compound primary key 456

6. The member attribute of1.10 composite primary key is associated with entity 458.

6. 1. 1 1 continuous propagation +06 1

6.2 Inheritance Mapping 462

6.2. 1 Adopt inheritance mapping of subclass elements 466.

6.2.2 Using inheritance mapping combined with subclass element 467

6.2.3 Adopt inheritance mapping 470 of elements of union subclass.

6.3 Batch Processing of Hibernate 472

6.3. 1 batch insert 473

Batch update 474

6.3.3 DML style batch update/deletion 474

6.4 using HQL query 476

HQL query 476

Hql query 6.4.2 in clause 478

6.4.3 Association and contact 478

6. 4. 4 HQL Query 48 1

6.4.5 Aggregation Function of HQL Query 482

Polymorphic query 483

6.4.7 Location of query in article 483 of HQL

Expression 484

6.4.9 Orders in Article 486

Grouping by clause 486

6.4. 1 1 subquery 487

Named query 488

6.5 conditional query 488

6.5. 1 association and dynamic association 49 1

6.5.2 Forecast, Summary and Grouping 492

6.5.3 Offline Query and Sub-query 495

6.6 SQL query 496

1 scalar query 496

6.6.2 Entity Inquiry 498

6.6.3 Dealing with association and inheritance

6.6.4 Named SQL Query 50 1

6.6.5 Calling Stored Procedure 502

Using custom SQL 503

6.7 Data Filtering 505

6.8 Transaction Control 508

6.8. 1 trading concept 508

6.8.2 Conversations and Transactions 509

6.8.3 Context-related Sessions 5 1 1

6.9 Secondary Cache and Query Cache 5 1 1

6.9. 1 Open the secondary cache 5 12.

6.9.2 Management Cache and Statistics Cache 5 15

Use query cache 5 16

6. 10 event mechanism 5 18

Interceptor 5 19

6. 10.2 Event System 22 1

6. 1 1 Summary of this chapter 525

Chapter VII Basic Usage of Spring 526

7. Introduction to1Spring and Changes of Spring 3.0 527

7. Introduction of1.1Spring 527

7. 1.2 spring change 3.0 528

7.2 Download and Installation of Spring 528

7.2. 1 Using Spring 528 in Java SE application

7.2.2 Using Spring 529 in Web Application

7.2.3 Developing Spring Application in Eclipse

7.3 Core Mechanism of Spring: Dependency Injection 533

Understanding dependency injection 533

7.3.2 Setting Injection 534

Structural injection 538

7.3.4 Comparison of two injection methods 539

7.4 Use spring container 539

7.4. 1 spring container 540

7.4.2 Use application context 54 1

7.4.3 Internationalization Support of Application Context 542

7.4.4 Event Mechanism of Application Context 544

7.4.5 Let the Bean get the Spring container 546.

7.5 beans in a spring container 548

7.5. Basic definition of1bean548

7.5.2 The range of Bean in the container is 55 1.

7.5.3 Configuration Dependencies 553

7.5.4 Setting Common Attribute Values 555

7.5.5 Configure Partner Bean 557

7.5.6 Inject automatically assembled partner Bean 557

7.5.7 injecting nested Bean 560

7.5.8 Injection setting value 56 1

Combination attribute name 565

7.5. 10 Spring Bean and JavaBean 566

Providing 7.6 Java Configuration Management 7.6 Spring 3.0 567

7.7 Bean instance creation method and dependency configuration 570

7.7. 1 Use the constructor to create a Bean instance 570.

7.7.2 Create Bean 572 by using static factory method.

7.7.3 Call instance factory method to create Bean 575

7.8 understand Bean 577 in the container deeply

7.8. 1 Use abstract Bean 577.

7.8.2 using child Bean 578

7.8.3 The difference between bean inheritance and Java inheritance 579

7.8.4 Factory beans in containers 580

7.8.5 get the id 582 of the Bean itself.

7.8.6 forced initialization of bean583

7.9 Life cycle of beans in containers 583

7.9. 1 behavior after dependency injection 584

7.9.2 Behavior before bean destruction 585

7.9.3 Coordinate beans with Asynchronous Range

7. 10 Learn more about dependency configuration 59 1

7. 10. 1 inject the property values of other Bean 592.

7. 10.2 Inject field values of other Bean 594.

7. 10.3 The method of injecting other Bean returns 595.

7. 1 1 Simplified configuration mode based on XML schema50000.00000000676

7. 1 1. 1 Configure attribute 599 with the p namespace.

7. 1 1.2 uses util mode 600.

7. 12 Expression Language (Spel) provided by Spring 3.0 602

7. 12. 1 Use the expression interface to calculate expression 603

7. The expression language in the definition of12.2 bean supports 604.

7. 12.3 SpEL Syntax Details 606

7. 13 Abstract of this chapter 6 1 1

Chapter 8 Deep Use of Spring 6 12

8. 1 two post-processors 6 13

8. 1. 1 bean post-processor 6 13

8. usefulness of1.2 bean post-processor 6 17

8. 1.3 container postprocessor 6 17

8. 1.4 Attribute Placeholder Configurator 6 19

8. 1.5 Rewriting Placeholder Configurator 620

The zero configuration of 8.2 Spring supports 62 1.

8.2. 1 search Bean class621

8.2.2 Specify the scope of Bean 624.

8.2.3 Using @Resource to Configure Dependencies 625

8.2.4 Use @PostConstruct and @ predestroy626 to customize the life cycle behavior.

8.2.5 Note 626 added 8.2.5 Spring 3.0.

8.2.6 Automatic Assembly and Precise Assembly 627

8.3 Resource Access 629

8.3. 1 Resource Implementation Class 630

8.3.2 Resource Loader Interface and Resource Loader Software Interface 635

8.3.3 Using Resources as Attributes 638

8.3.4 Using Resources in Application Context 639

8.4 AOP 643 of Spring

Why does 8.4. 1 need AOP 643?

8.4.2 Implementing AOP 644 with AspectJ

Basic concepts of AOP 649

The AOP of the spring bracket is 650.

8.4.5 "Zero Configuration" mode based on Note 65 1

8.4.6 Management mode based on XML configuration file 666

8.5 Spring Trading 672

8.5. 1 trading strategy supported by Spring 673

8.5.2 Create a transaction proxy using TransactionProxyFactoryBean 678.

8.5.3 Transaction allocation strategy 8.5.3 Spring 2. X 68 1

8.5.4 Use @ Transaction 685

8.6 Spring integrated strut 2 686

6. 1 Start the spring container 686

Reflections on the integration of MVC framework and spring30000.00000000606

8.6.3 Let Spring manage the controller 689

Using automatic assembly 692

8.7 Spring integration Hibernate 695

8.7. DAO support provided by1spring695.

8.7.2 Managing Hibernate's Session Factory 696

8.7.3 Using hibernation template 697

Use HibernateCallback 70 1

8.7.5 Implementing DAO component 703

8.7.6 Assembling various components using IoC containers 705

8.7.7 Using declarative transactions 707

8.8 spring integration JPA 708

Manage EntityManager 709

Use JpaTemplate 7 1 1

Using JPA to call back 7 13

8.8.4 Implement DAO component 7 14 with JpaDaoSupport.

8.8.5 Using declarative transactions 7 14

8.9 Overview of this chapter 7 15

Chapter 9 Ideas and Strategies of Enterprise Application Development 7 16

9. 1 Challenges faced by enterprise application development 7 17

9. 1. 1 Extensibility and scalability 7 17

9. 1.2 Rapid and controllable development 7 18

9. 1.3 stable and efficient 7 19

9. 1.4 Minimize expenditure and maximize income 7 19

9.2 How to Face Challenges 7 19

Using modeling tool 7 19

9.2.2 Use excellent framework 720

9.2.3 Selective extension 722

9.2.4 Using Code Generator 722

9.3 Introduction to Common Design Patterns 722

9.3. 1 single mode 723

Simple factory 724

Factory methods and abstract factories 730

Proxy mode 733

Command mode 739

9.3.6 Strategy Mode 74 1

9.3.7 Elevation mode 743

Bridge mode 746

9.3.9 Observer Mode 750

9.4 General Architecture Design Strategy 753

9.4. 1 anemia model 753

9.4.2 Domain Object Model 756

9.4.3 Merge business logic objects with DAO objects 758

9.4.4 Merge business logic objects and domain objects 759.

9.4.5 Abandon business logic layer 76 1

9.5 Overview of this chapter 762

Chapter 10 Simple workflow system 763

10. 1 project background and system structure 764

10. 1. 1 application background 764

10. 1.2 system function introduction 764

10. 1.3 related technology introduction

10. 1.4 system structure 766

10. 1.5 Function module of system 766

10.2 dormant persistence layer 767

10. 2. 1 design persistent entity 767

10.2.2 Create Persistent Entity Class 768

10.2.3 mapping persistent entity 772

10.3 implements DAO layer 777.

Definition of 10. 3. 1 DAO component 778

10.3.2 implementing DAO component 783

10.3.3 Deploying DAO Layer 787

Implementation of 10.4 service layer 789

10.4. 1 business logic component design 789

10.4.2 implementing business logic component 789

10.4.3 transaction management 795

10.4.4 Deploying Business Logic Component 795

Realizing automatic scheduling of tasks 797

10.5. 1 use Shi Ying 797.

10.5.2 use Shi Ying 802 in spring.

10.6 implements the system Web layer 804.

10.6. 1 strut 2 and spring integration 804

10.6.2 processing sequence of controller 805

10.6.3 employee login 806

10.6.4 Enter the clock-in 808.

10.6.5 processing punch cards 8 10.

10.6.6 Enter the application 8 1 1.

Submit an application 8 12

10.6.8 Using Interceptor to Complete Authority Management 8 14

10.7 Summary of this chapter 8 16