- 1.方式一:IDEA配置
- 步驟一:點擊edit configurations...步驟2:點擊Environment步驟3:點擊working directory 選擇第三個,然後點擊apply,ok就能訪問jsp頁面
- 2.方式二:添加一個配置文件
@Configuration
public class GlobalConfig {
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> customizer() {
return (factory) -> {
factory.addContextCustomizers((context) -> {
//模塊中webapp相對路徑
String relativePath = "tt-web/src/main/webapp";
File docBaseFile = new File(relativePath);
// 路徑是否存在
if (docBaseFile.exists()) {
context.setDocBase(docBaseFile.getAbsolutePath());
}
}
);
};
}
}