我有一个映射的网址到/foo.jsp
重定向到控制器,但它不是由spring处理并返回404.似乎该url被忽略并直接发送到tomcat。是否有可能使弹簧处理它?</ p>
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController("/foo", "/").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
registry.addRedirectViewController("/foo.html", "/").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
registry.addRedirectViewController("/foo.jsp", "/").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
}
}
然后导航到/foo
和/foo.html
按预期工作,但/foo.jsp
会返回404