我试图在我们的春季启动应用程序中集成Angular i18n模块,并且我在base href方面遇到了一些问题。 我为每种语言构建了我们的应用程序' de'和' en'比如herestrings然后将我的资源复制到后端。
Hier是我在package.json中的构建脚本,用于prod:
"scripts": {
"ng": "ng",
"start-local": "ng serve --env=local",
"build": "ng build",
"buildProd": "for lang in de en; do ng build --output-path=dist/$lang -prod --bh /$lang/ --i18n-file=src/i18n/messages.$lang.xlf --i18n-format=xlf --locale=$lang; done",
"test": "ng test",
"test-coverage": "ng test --code-coverage",
"lint": "ng lint",
"e2e": "ng e2e",
"i18n": "ng xi18n --output-path src/i18n"
}
对于Spring配置,我这样做了:
@EnableEurekaClient
@SpringBootApplication
public class ProviderApplication extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/myapp/de/**").setViewName("/de/index.html");
registry.addViewController("/myapp/en/**").setViewName("/en/index.html");
}
public static void main(String[] args) {
SpringApplication.run(UiProviderApplication.class, args);
}
}
当我尝试在我的浏览器中提供此网址时... / myapp / de然后我将获得/ de / myapp / de这是基本的href部分' de'或者' en'。
如何从网址中删除基本href?我做错了什么?
感谢您的帮助 利
答案 0 :(得分:0)
- deploy-url = / $ lang /而不是base-href解决了我的问题