好的。我感到难过。我一直在尝试让Spring Boot“查看”静态组件(例如图像和CSS),但不断遇到映射问题,例如“ GET /Employee/css/SSI/dialog.css没有映射”。该修补程序似乎很简单,只需确保.css文件位于正确的位置即可找到并且拼写一致。我尝试了几种变体,但解决方案使我无所适从。我不知道是否有人看到我没看到的东西。
Eclipse中的项目结构: 员工/src/main/resources/public/css/SSI/dialog.css
Employee / src / main / webapp / template.jsp
template.jsp
在该元素内,以下内容似乎有效:“ /public/css/SSI/dialog.css” rel =“ stylesheet” type =“ text / css” />“,因为它以” GET“ / Employee / public / css / SSI / dialog.css“,参数= {}”
但是,这会产生“没有GET /Employee/public/SSI/dialog.css的映射”
如果有线索,我还将包括我的AppConfig.jsp。
package mil.dfas.springmvc.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
@Configuration
@EnableWebMvc
public class AppConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//Register resource handler for CSS and JS
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/public/css/");
//Register resource handler for images
registry.addResourceHandler("/images/**").addResourceLocations("/WEB-INF/images/");
}
@Bean
public InternalResourceViewResolver resolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setViewClass(JstlView.class);
resolver.setPrefix("/");
resolver.setSuffix(".jsp");
return resolver;
}
}