Giter Site home page Giter Site logo

mpalourdio / springbootangularhtml5 Goto Github PK

View Code? Open in Web Editor NEW
88.0 7.0 43.0 5.24 MB

:hotsprings: Spring Boot 3 + Angular + HTML5 router mode + HTTP interceptor + Lazy loaded modules

License: MIT License

HTML 3.77% JavaScript 4.32% Java 34.83% TypeScript 56.00% Dockerfile 0.72% SCSS 0.37%
font-awesome spring-boot maven karma jasmine typescript html5 angular angular-cli angular2

springbootangularhtml5's Introduction

Build Status Build Status

This project is available in Kotlin too. Take a look at this repository.

Spring Boot 3.x and Angular with HTML 5 router

This project provides an example of an Angular single page application, served by Tomcat, configured with the html5 router. Some endpoints have Spring Webflux integration too.

The SinglePageAppConfig makes the magic here.

The base-href in configured by the ResourceResolver. It's generated from the value of the application's context-path at runtime when served by tomcat.

It's useful if you want to serve an Angular application with the html5 router, and avoid the dashed URL.

This html5 router mode makes pretty URL, but has a default : Refreshing pages (or accessing them directly) will give you a 404 HTTP error if no RewriteRule is provided by the HTTP server that serves the application.

Handling the base-href dynamically can be tricky too. Here it's done once and for all by the ResourceResolver.

This project includes a custom HTTP interceptor. It's useful to show a loader during long HTTP requests for example.

To test the fully built project, run SpringBootAngularHTML5Application after an ./mvnw clean install -Pfront, and point your browser to http://localhost:10000/my-context/path.

If you want to play with the front part, go to the front folder and run yarn start or npm start. HTTP requests will be correctly proxyfied to your backend.

The front-end part has been scaffolded with angular-cli.

springbootangularhtml5's People

Contributors

dependabot[bot] avatar mpalourdio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

springbootangularhtml5's Issues

Not a issue,Need help if you came through same scenario

I have a SpringBootAngular app, we build angular components separately and put them in "resources/static"folder of SpringBoot project.It is working fine when i start the SpringBoot project.

But My project was access from different parent app hosted in different server when they access our app URL they send user info through request cookie and i am able to see those cookies in my server using Spring GetMapping(*).

My scenario is ,After getting those request cookie we need to server angular component,I have tried below code.However it is not working.
@controller
public class ViewController {
@GetMapping("*")
public String handleTestRequestAll(HttpServletRequest request,HttpServletResponse response){

	System.out.println("ViewController:*:printing req cookies for all-----------------");
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        Arrays.stream(cookies)
              .forEach(c -> System.out.println(c.getName() + "=" + c.getValue()));
    }
    return "forward:/";   
}

base-href replacement and server context

First of all, thanks! Two small notes:

  • I see the replacement pattern #base-href#, but I see it used nowhere. index.html has no tag.
  • I think the servlet context is not correctly read when this is ran in a tomcat instance. So instead of using the properties directly, use the javax.servlet.ServletContext.

Multi-Module project?

Hi,

I was wondering why you didn't create a multi module project with maven. So you can have a module for the frontend, backend and distribution (e.g. create installer).

Otherwise a nice repo to start with a project!

Application does not load on chrome and safari

Hello the application does not load on Chrome/Safari and keeps on showing "Loading.." message. Nor do I see any errors in console. Am I missing something here?

Works great on Firefox though.

Static html serve issue

Hey this repo is really awosome ..

This helped me to serve angular from spring boot with html5 url

but this broke my static files from public folder
i have graph html files and corrospoding js files
i request these html directly by passing URL params which are picked by js to render those graphs .. this i needed to make these to png and send thro email
stuck on these public folder access ... previously all was well

you help will be appreciated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.