gpt4 book ai didi

java - 使用spring从jar文件访问静态html页面

转载 作者:行者123 更新时间:2023-12-02 08:19:58 25 4
gpt4 key购买 nike

我想使用 spring 调用/WEB-INF/lib 下 jar 中的 home.html 文件。

下面是配置类

@Configuration
@ComponentScan("com.barclays.mobile.gateway.controller")
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter{

@Bean(name = "viewResolver")
public InternalResourceViewResolver getViewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/");
viewResolver.setSuffix(".html");
return viewResolver;
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/component/**").addResourceLocations("classpath:/app/component/*");
registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/app/assets/*");
registry.addResourceHandler("/home/**").addResourceLocations("classpath:/app/*");
}

}

下面是 Controller :

@Controller
public class StaffController {

@RequestMapping(value = "/home", method = RequestMethod.GET)
public String home() {
return "home";
}
}

请建议如何执行此操作。?

最佳答案

/home 中删除 /,我猜这就是问题所在

关于java - 使用spring从jar文件访问静态html页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30452316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com