调度程序 servlet 无法在 Spring Boot 3.2.4 中找到视图
温馨提示:
本文最后更新于 2024年04月12日,已超过 37 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
I am getting an error saying, DispatcherServlet - Completed 404 Not found. My project is packaged as a jar and the jsps are located in src/main/resources/META-INF/resources/jsp.
In my application.properties have given:
spring.mvc.view.prefix=/META-INF/resources/jsp/ spring.mvc.view.suffix=.jsp
I expanded my jar file using Java decompiler and the jsps are present in /META-INF/resources/jsp.
I tried setting the view path from Config file, but it did not work.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view. InternalResourceViewResolver;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers (ResourceHandlerRegistry registry) {
registry.addResourceHandler("/META-INF/resources/jsp/**");
.addResourceLocations("classpath:/META-INF/resources/jsp/", ".jsp");
}
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver resolver new Internal ResourceViewResolver();
resolver.setPrefix("/META-INF/resources/jsp/");
resolver.setSuffix(".jsp");
return resolver;
}}
正文到此结束
- 本文标签: 家庭宠物
- 本文链接: https://www.coder6.net/article/2430
- 版权声明: 本文由蚂蚁原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权