如您所知,在XML中,配置它的方法是:
<error-page>
<error-code>404</error-code>
<location>/my-custom-page-not-found.html</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)
但我还没有找到一种方法在Java配置中执行此操作.我尝试的第一种方式是:
@RequestMapping(value = "/**")
public String Error(){
return "error";
}
Run Code Online (Sandbox Code Playgroud)
它似乎工作,但它检索资源有冲突.
有办法吗?