Building Web Apps with Spring 5 and Angular
eBook - ePub

Building Web Apps with Spring 5 and Angular

  1. 370 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Building Web Apps with Spring 5 and Angular

About this book

A complete guide to build robust and scalable web applications with Spring and Angular.About This Book• This hands on guide will teach you how to build an end-to-end modern web application using Spring and Angular.• It is easy to read and will benefit Java developers who have been used to develop the back-end part of web application while front-end (UI) has been left for UI developers.• Learn the core aspects involved in developing the backend and the UI, right from designing to integrating and deploying.Who This Book Is ForThis book is targeted towards Java Web Developers with a basic knowledge of Spring who want to build complete web applications in a fast and effective way. They will want to gain a stronghold on both frontend and backend development to advance in their careers.What You Will Learn• Set up development environment for Spring Web App and Angular app.• Process web request and response and build REST API endpoints.• Create data access components using Spring Web MVC framework and Hibernate• Use Junit 5 to test your application• Learn the fundamental concepts around building Angular• Configure and use Routes and Components.• Protect Angular app content from common web vulnerabilities and attacks.• Integrate Angular apps with Spring Boot Web API endpoints• Deploy the web application based on CI and CD using Jenkins and Docker containersIn DetailSpring is the most popular application development framework being adopted by millions of developers around the world to create high performing, easily testable, reusable code. Its lightweight nature and extensibility helps you write robust and highly-scalable server-side web applications. Coupled with the power and efficiency of Angular, creating web applications has never been easier.If you want build end-to-end modern web application using Spring and Angular, then this book is for you.The book directly heads to show you how to create the backend with Spring, showing you how to configure the Spring MVC and handle Web requests. It will take you through the key aspects such as building REST API endpoints, using Hibernate, working with Junit 5 etc. Once you have secured and tested the backend, we will go ahead and start working on the front end with Angular. You will learn about fundamentals of Angular and Typescript and create an SPA using components, routing etc. Finally, you will see how to integrate both the applications with REST protocol and deploy the application using tools such as Jenkins and Docker.Style and approachThis is a straightforward guide that shows how to build a complete web application in Angular and Spring.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Building Web Apps with Spring 5 and Angular by Ajitesh Shukla in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Java. We have over one million books available in our catalogue for you to explore.

Information

Creating SPA with Angular and Spring 5

Navigating through different pages/views in an effective manner is the most important aspect of creating a single page app (SPA). This is where routing comes into picture. Angular provides different concepts in relation to implementing routing in order to achieve navigation from one view to another. In this chapter, we will learn concepts such as the following to create single page applications (SPAs) using Angular and Spring 5:
  • Introduction to routing
  • Configuring route definitions
  • RouterLink for navigation
  • Route Guards for access control
  • Routing configuration design patterns
  • Creating a single page app
  • Debugging Angular app

Introduction to routing

The routing concept in relation to web applications represents the ability to do some of the following:
  • Navigate to different pages, for example, from one page to another, or, from one view to another by clicking on a URL
  • Navigate back and forward through the history of pages using the back and forward button of the browser
The Angular router helps to achieve the earlier mentioned capability of moving from one view to another while users work through the application. When the browser's URL changes, the router looks for a corresponding route from which it can determine the component to display. The following are some key aspects which need to be taken care of while working with the Angular router:
  • Add a base element in index.html. This instructs Angular Router to create navigation URLs for different views. The following code can be found within the <head> tag in index.html. While moving the app to production, the base href need to be set to appropriate path such as "/" (instead of "./") or any other context path. For example, if angular app is available at path, http://www.somewebsite.com/my/app/, the base href needs to be set to /my/app/.
 <base href="./">
  • Create route definitions in the appropriate routing module. The route definitions can be created within AppModule, root module, as a separate routing module at the root level, or as a routing module specific to each of the feature modules. The details on different techniques based on which route definitions can be created has been detailed in one of the later sections.
  • In case route definitions are defined as a separate module, import the routing module in the root module, as appropriate, either in AppModule or in the feature module. This is demonstrated in later this chapter.

Configuring Route definitions

Route definitions represent association of one or more URL paths to the respective components. Each of these route definitions can also be termed as a route. Route definitions or routes, are stored in an array and loaded using Router.forRoot or Router.forChild API depending upon whether routes are defined at root level or submodule/feature module level. When the users click on the hyperlink (URL), the router looks for the corresponding route, and based on appropriate path matching strategy (prefix by default) determines the component to display. The following are the key steps to configure route definitions:
  • Define route definitions in the form of an array of routes. The following code represents route definitions where no parameters are passed (such as new user registration and user login), and one ...

Table of contents

  1. Title Page
  2. Copyright
  3. Credits
  4. About the Author
  5. About the Reviewer
  6. www.PacktPub.com
  7. Customer Feedback
  8. Preface
  9. Introduction to Spring Web Framework
  10. Preparing the Spring Web Development Environment
  11. Data Access Layer with Spring and Hibernate
  12. Testing and Running Spring Web App
  13. Securing Web App with Spring Security
  14. Getting Started with Angular
  15. Creating SPA with Angular and Spring 5
  16. Unit Testing with Angular Apps
  17. Securing an Angular App
  18. Integrating Angular App with Spring Web APIs
  19. Deploying the Web Application