JHipster非角度登陆页面

时间:2016-09-11 23:34:30

标签: angular spring-boot jhipster

我想在JHipster项目中使用普通的html视图作为登陆页面。 Spring-Boot控制器是否有最佳实践?我的目标是为路径“/”使用非角度html页面。 angular-index.html由spring boot默认值自动加载。我不明白我如何使用弹簧靴的这种自动配置,同时对路径有一个非角度的视图“/".

@RequestMapping("/")
public String hi() {
    return "hi";
}

这是呈现位于/ resources / templates中的“hi.html”视图的方法。视图显示正确但我无法再解决角度应用程序(例如/ home)。

1 个答案:

答案 0 :(得分:0)

JSHipster -可以使用html5路由,这意味着当您转到Root时JSHipset在浏览器上使用路由。由此得出结论,它使用了角路由。

但是,当您使用路由'/ api / *'的一部分时,它将进行后端路由。您可以在application.yml中配置此路由。

enter image description here

问题是当您转到rootPath jHipset转到index.html时,它是Angular应用程序。

我认为好的做法是在服务器上设置重定向。

Jhipster 可以与NGINX一起使用。

您必须创建一个src/main/docker/nginx.yml Docker Compose文件:

version: '2'
services:
  nginx:
    image: nginx:1.13-alpine
    volumes:
    - ./../../../target/www:/usr/share/nginx/html
    - ./nginx/site.conf:/etc/nginx/conf.d/default.conf
    ports:
    - "8000:80"

添加。/nginx/site.conf并配置:

server {
    listen 80;
    index index.html;
    server_name localhost;
    error_log  /var/log/nginx/error.log;

    location / {
        root /usr/share/nginx/html; //add path to another html file
    }
    location /api {
        proxy_pass http://api.jhipster.tech:8081/api;
    }
    location /front {
        proxy_pass http://api.jhipster.tech:8081/;
    }

    ...
}

规则location /,您可以更改为自定义网址(无角度视图)。

相关问题