如果你正在开发Spring Boot应用程序,请在主文件中添加“ SpringBootServletInitializer”,如以下代码所示。因为如果没有SpringBootServletInitializer,Tomcat会将其视为普通应用程序,则不会将其视为Spring引导应用程序。
@SpringBootApplication
public class DemoApplication extends *SpringBootServletInitializer*{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication .class);
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication .class, args);
}
}
我为此问题挣扎过很多次。
我当前使用的解决方案是在webapp(或保存了jsp之类的视图的文件夹)处于部署程序集下。
这样做Right click on the project > Build Path > Configure Build path > Deployment Assembly > Add(right hand side) > Folder > (add your jsp
文件夹。在默认情况下为src/main/webapp)
在你做完所有正确的事情之后,你也可能会收到此错误,但是在JSP上,你将锚标记放置为旧的样式(如果有其他问题,我会添加此标签以防其他人)。
我在jsp上具有以下语法。<a href="/mappedpath">TakeMeToTheController</a>
而且我一直看到问题中提到的错误。但是,将标签更改为如下所示的标签可以解决此问题。
<a href=" <spring:url value="/mappedpath" /> ">TakeMeToTheController</a>