im尝试创建一个默认 requestmapping ,它将所有请求重定向到 index.htex.html 在我的单页应用程序
中我当前的解决方案是
@RequestMapping(value="/**/{[path:[^\.]*}")
public String index() {
return "index";
}
和属性:
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.html
我建立一个社交网络,如果我创建
之类的路径,它可以正常工作http://localhost:8080/user1337
但是当我在路径中使用点时,它会失败:
http://localhost:8080/user.1337
我获得了一个错误页面:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Sep 18 23:19:22 CEST 2017
There was an unexpected error (type=Not Found, status=404).
No message available
@RequestMapping(value="{path:.*}")
这个模式
[^\.]
匹配任何非或
或
.
的字符,因此您的模式将与其中的.
匹配,因此不会将其匹配,因此不会重定向到索引。