【发布时间】:2018-02-27 12:39:36
【问题描述】:
我正在尝试创建一个默认的 RequestMapping,它将所有请求重定向到我的单页应用程序中的 index.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
【问题讨论】:
-
也许你想匹配任何路径?
{[path:.*}? -
当我匹配任何路径时,我得到一个异常... ServletException: Circular view path [/index.html]: 将再次调度回当前处理程序 URL [/index.html]。检查您的 ViewResolver 设置! (提示:由于默认视图名称生成,这可能是未指定视图的结果。)
标签: regex angular spring-boot single-page-application