以下是我的情景:
塞纳里奥:
我的网址将是
https://localhost:9443/consumer https://localhost:9443/consumer/preapproval https://localhost:9443/consumer/preapproval/的申请人 https://localhost:9443/consumer/preapproval/的客户端
每次点击整个/整个网址都不会改变。如果我使用以下配置:
`@Configuration 公共类WebConfig扩展了WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index.html");
}
@Bean
public InternalResourceViewResolver defaultViewResolver() {
return new InternalResourceViewResolver();
}
}`
在spring boot中,当我刷新/输入(https://localhost:9443/consumer)以外的任何URL时,它会抛出404错误。任何人都可以建议我最好的解决方案。
注意:在我的业务中,我们不应该在Angular 4中使用hashcode。
提前致谢
答案 0 :(得分:0)
我在项目中设置了一个类似于下面的getMapping。
@GetMapping("/{path:[^\\.]*}")
String redirect() {
return "forward:/";
}