在b站上看黑马程序员的瑞吉外卖项目练手。由于在day1里面,黑马的视频中没有把前端页面放入static资源里,而是配置了一个WebMvcConfig类,我直接把前端页面放入了static里,没有配置这个类。
而在day2里面需要解决js数据只能处理16位的问题,在WebMvcConfig类中又配置了一个方法,我配置好这个方法后,登入页面发现index.html页面找不到了。
This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Not Found, status=404).
解决办法:在WebMvcConfig类中加入addResourceHandlers 函数,代码如下:
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("backend/**").addResourceLocations("classpath:/static/backend/");
registry.addResourceHandler("front/**").addResourceLocations("classpath:/static/front/");
}
再次运行,即可成功进入index.html页面。